|
| 1 | +# Operations |
| 2 | + |
| 3 | +A conformant runtime MUST provide an executable (called `funC` in the following examples). |
| 4 | +That executable MUST support commands with the following template: |
| 5 | + |
| 6 | +```sh |
| 7 | +$ funC [global-options] <COMMAND> [command-specific-options] <command-specific-arguments> |
| 8 | +``` |
| 9 | + |
| 10 | +## Global options |
| 11 | + |
| 12 | +None are required, but the runtime MAY support options that start with at least one hyphen. |
| 13 | +Global options MAY take positional arguments (e.g. `--log-level debug`). |
| 14 | +Command names MUST not start with hyphens. |
| 15 | +The option parsing MUST be such that `funC <COMMAND>` is unambiguously an invocation of `<COMMAND>` (even for commands not specified in this document). |
| 16 | +If the runtime is invoked with an unrecognized command, it MUST exit with a nonzero exit code and MAY log a warning to stderr. |
| 17 | + |
| 18 | +## Character encodings |
| 19 | + |
| 20 | +This API specification does not cover character encodings, but runtimes SHOULD conform to their native operating system. |
| 21 | +For example, POSIX systems define [`LANG` and related environment variables][posix-lang] for [declaring][posix-locale-encoding] [locale-specific character encodings][posix-encoding], so a runtime in an `en_US.UTF-8` locale SHOULD write its [version](#version) to stdout in [UTF-8][]. |
| 22 | + |
| 23 | +## Commands |
| 24 | + |
| 25 | +### version |
| 26 | + |
| 27 | +Print the runtime version and exit. |
| 28 | + |
| 29 | +* *Options* None are required, but the runtime MAY support options. |
| 30 | +* *Standard streams* |
| 31 | + * *stdin:* The runtime MUST NOT attempt to read from its stdin. |
| 32 | + * *stdout:* The runtime MUST print its name, a space, and its version as the first line to its stdout. |
| 33 | + The name MAY contain any Unicode characters, but MUST NOT contain control codes or newlines. |
| 34 | + The runtime MAY print additional lines to its stdout, and the format for those lines is not specified in this document. |
| 35 | + * *stderr:* The runtime MAY print diagnostic messages to stderr, and the format for those lines is not specified in this document. |
| 36 | +* *Exit code:* The runtime MUST exit with zero. |
| 37 | + |
| 38 | +#### Example |
| 39 | + |
| 40 | +``` |
| 41 | +$ funC version |
| 42 | +funC 1.0.0 |
| 43 | +Built for x86_64-pc-linux-gnu |
| 44 | +$ echo $? |
| 45 | +0 |
| 46 | +``` |
| 47 | + |
| 48 | +### start |
| 49 | + |
| 50 | +Start a container from a bundle directory. |
| 51 | + |
| 52 | +* *Options* |
| 53 | + * *`--id <ID>`* Set the container ID when creating or joining a container. |
| 54 | + If not set, the runtime is free to pick any ID that is not already in use. |
| 55 | + * *`--bundle <PATH>`* Override the path to the bundle directory (defaults to the current working directory). |
| 56 | +* *Standard streams:* The runtime MUST attach its standard streams directly to the application process without inspection. |
| 57 | +* *Environment variables* |
| 58 | + * *`LISTEN_FDS`:* The number of file descriptors passed. |
| 59 | + For example, `LISTEN_FDS=2` would mean that the runtime MUST pass file descriptors 3 and 4 to the application process (in addition to the [standard streams][standard-streams]) to support [socket activation][systemd-listen-fds]. |
| 60 | +* *Exit code:* The runtime MUST exit with the application process's exit code. |
| 61 | + |
| 62 | +#### Example |
| 63 | + |
| 64 | +``` |
| 65 | +# in a bundle directory with a process that echos "hello" and exits 42 |
| 66 | +$ funC start --id hello-1 |
| 67 | +hello |
| 68 | +
|
| 69 | +$ echo $? |
| 70 | +42 |
| 71 | +``` |
| 72 | + |
| 73 | +### state |
| 74 | + |
| 75 | +Request the container state. |
| 76 | + |
| 77 | +* *Arguments* |
| 78 | + * *`<ID>`* The container whose state is being requested. |
| 79 | +* *Standard streams:* |
| 80 | + * *stdin:* The runtime MUST NOT attempt to read from its stdin. |
| 81 | + * *stdout:* The runtime MUST print the state JSON to its stdout. |
| 82 | + * *stderr:* The runtime MAY print diagnostic messages to stderr, and the format for those lines is not specified in this document. |
| 83 | +* *Exit code:* Zero if the state was successfully written to stdout and non-zero on errors. |
| 84 | + |
| 85 | +#### Example |
| 86 | + |
| 87 | +``` |
| 88 | +# in a bundle directory with a process that sleeps for several seconds |
| 89 | +$ funC start --id sleeper-1 & |
| 90 | +$ funC state sleeper-1 |
| 91 | +{ |
| 92 | + "ociVersion": "1.0.0-rc1", |
| 93 | + "id": "sleeper-1", |
| 94 | + "status": "running", |
| 95 | + "pid": 4422, |
| 96 | + "bundlePath": "/containers/sleeper", |
| 97 | + "annotations" { |
| 98 | + "myKey": "myValue" |
| 99 | + } |
| 100 | +} |
| 101 | +$ echo $? |
| 102 | +0 |
| 103 | +``` |
| 104 | + |
| 105 | +[posix-encoding]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap06.html#tag_06_02 |
| 106 | +[posix-lang]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_02 |
| 107 | +[posix-locale-encoding]: http://www.unicode.org/reports/tr35/#Bundle_vs_Item_Lookup |
| 108 | +[standard-streams]: https://github.com/opencontainers/specs/blob/v0.1.1/runtime-linux.md#file-descriptors |
| 109 | +[systemd-listen-fds]: http://www.freedesktop.org/software/systemd/man/sd_listen_fds.html |
| 110 | +[UTF-8]: http://www.unicode.org/versions/Unicode8.0.0/ch03.pdf |
0 commit comments