|
2 | 2 |
|
3 | 3 | ## State |
4 | 4 |
|
5 | | -The runtime state for a container is persisted on disk so that external tools can consume and act on this information. |
6 | | -The runtime state is stored in a JSON encoded file. |
7 | | -It is recommended that this file is stored in a temporary filesystem so that it can be removed on a system reboot. |
8 | | -On Linux based systems the state information should be stored in `/run/opencontainer/containers`. |
9 | | -The directory structure for a container is `/run/opencontainer/containers/<containerID>/state.json`. |
10 | | -By providing a default location that container state is stored external applications can find all containers running on a system. |
11 | | - |
12 | | -* **`version`** (string) Version of the OCI specification used when creating the container. |
13 | | -* **`id`** (string) ID is the container's ID. |
14 | | -* **`pid`** (int) Pid is the ID of the main process within the container. |
15 | | -* **`bundlePath`** (string) BundlePath is the path to the container's bundle directory. |
16 | | - |
| 5 | +Runtime MUST store container metadata on disk so that external tools can consume and act on this information. |
| 6 | +It is recommended that this data be stored in a temporary filesystem so that it can be removed on a system reboot. |
| 7 | +On Linux/Unix based systems the metadata MUST be stored under `/run/opencontainer/containers`. |
| 8 | +For non-Linux/Unix based systems the location of the root metadata directory is currently undefined. |
| 9 | +Within that directory there MUST be one directory for each container created, where the name of the directory MUST be the ID of the container. |
| 10 | +For example: for a Linux container with an ID of `173975398351`, there will be a corresponding directory: `/run/opencontainer/containers/173975398351`. |
| 11 | +Within each container's directory, there MUST be a JSON encoded file called `state.json` that contains the runtime state of the container. |
| 12 | +For example: `/run/opencontainer/containers/173975398351/state.json`. |
| 13 | + |
| 14 | +The `state.json` file MUST contain all of the following properties: |
| 15 | + |
| 16 | +* **`version`**: (string) is the OCF specification version used when creating the container. |
| 17 | +* **`id`**: (string) is the container's ID. |
| 18 | +This MUST be unique across all containers on this host. |
| 19 | +There is no requirement that it be unique across hosts. |
17 | 20 | The ID is provided in the state because hooks will be executed with the state as the payload. |
18 | | -This allows the hook to perform clean and teardown logic after the runtime destroys its own state. |
19 | | - |
20 | | -The root directory to the bundle is provided in the state so that consumers can find the container's configuration and rootfs where it is located on the host's filesystem. |
| 21 | +This allows the hooks to perform cleanup and teardown logic after the runtime destroys its own state. |
| 22 | +* **`pid`**: (int) is the ID of the main process within the container, as seen by the host. |
| 23 | +* **`bundlePath`**: (string) is the absolute path to the container's bundle directory. |
| 24 | +This is provided so that consumers can find the container's configuration and root filesystem on the host. |
21 | 25 |
|
22 | 26 | *Example* |
23 | 27 |
|
|
0 commit comments