|
2 | 2 |
|
3 | 3 | ## State |
4 | 4 |
|
5 | | -Runtime MUST store container metadata on disk so that external tools can consume and act on this information. |
| 5 | +An OCI compliant runtime MUST store container metadata on disk so that external tools can consume and act on this information. |
6 | 6 | It is recommended that this data be stored in a temporary filesystem so that it can be removed on a system reboot. |
7 | 7 | On Linux/Unix based systems the metadata MUST be stored under `/run/opencontainer/containers`. |
8 | 8 | For non-Linux/Unix based systems the location of the root metadata directory is currently undefined. |
@@ -37,23 +37,85 @@ This is provided so that consumers can find the container's configuration and ro |
37 | 37 | ## Lifecycle |
38 | 38 | The lifecycle describes the timeline of events that happen from when a container is created to when it ceases to exist. |
39 | 39 |
|
40 | | -1. OCI compliant runtime is invoked by passing the bundle path as argument. |
41 | | -2. The container's runtime environment is created according to the configuration in `config.json` and `runtime.json`. |
42 | | - Any updates to `config.json` or `runtime.json` after container is running do not affect the container. |
43 | | -3. The container's state.json file is written to the filesystem. |
44 | | -4. The prestart hooks are invoked by the runtime. |
45 | | - If any prestart hook fails, then the container is stopped and the lifecycle continues at step 8. |
46 | | -5. The user specified process is executed in the container. |
47 | | -6. The poststart hooks are invoked by the runtime. |
48 | | - If any poststart hook fails, then the container is stopped and the lifecycle continues at step 8. |
49 | | -7. Additional actions such as pausing the container, resuming the container or signaling the container may be performed using the runtime interface. |
50 | | - The container could also error out or crash. |
51 | | -8. The container is destroyed by undoing the steps performed during create phase (step 2). |
52 | | -9. The poststop hooks are invoked by the runtime and errors, if any, are logged. |
53 | | -10. The state.json file associated with the container is removed and the return code of the container's user specified process is returned or logged. |
| 40 | +1. OCI compliant runtime is invoked with a reference to the location of the bundle. |
| 41 | + How this reference is passed to the runtime is an implementation detail. |
| 42 | +2. The container's runtime environment MUST be created according to the configuration in `config.json` and `runtime.json`. |
| 43 | + Any updates to `config.json` or `runtime.json` after container is running MUST not affect the container. |
| 44 | +3. The container's `state.json` file MUST be written to the filesystem. |
| 45 | +4. The prestart hooks MUST be invoked by the runtime. |
| 46 | + If any prestart hook fails, then the container MUST be stopped and the lifecycle continues at step 8. |
| 47 | +5. The user specified process MUST be executed in the container. |
| 48 | +6. The poststart hooks MUST be invoked by the runtime. |
| 49 | + If any poststart hook fails, then the container MUST be stopped and the lifecycle continues at step 8. |
| 50 | +7. Additional actions such as pausing the container, resuming the container or signaling the container MAY be performed using the runtime interface. |
| 51 | + The container MAY also error out, exit or crash. |
| 52 | +8. The container MUST be destroyed by undoing the steps performed during create phase (step 2). |
| 53 | +9. The poststop hooks MUST be invoked by the runtime and errors, if any, MAY be logged. |
| 54 | +10. The `state.json` file associated with the container MUST be removed and the return code of the container's user specified process MUST be returned or logged. |
54 | 55 |
|
55 | 56 | Note: The lifecycle is a WIP and it will evolve as we have more use cases and more information on the viability of a separate create phase. |
56 | 57 |
|
| 58 | +## Operations |
| 59 | + |
| 60 | +OCI compliant runtimes MUST support the following operations, unless the operation is not supported by the base operating system. |
| 61 | + |
| 62 | +### Errors |
| 63 | +In cases where the specified operation generates an error, this specification does not mandate how, or even if, that error is returned or exposed to the user of an implementation. |
| 64 | +Unless otherwise stated, generating an error MUST leave the state of the environment as if the operation were never attempted - modulo any possible trivial ancillary changes such as logging. |
| 65 | + |
| 66 | +### Start |
| 67 | + |
| 68 | +Using the `config.json` and `runtime.json` files, along with the filesystem path referenced in the `config.json`, this operation MUST create a new container. |
| 69 | +This includes creating the relevant namespaces, cgroups and configuring the appropriate capabilities for the container. |
| 70 | +A new process in the container's PID namespace MUST be created as specified by the `config.json` file. |
| 71 | +Attempting to start an already running container MUST have no effect on the container and MUST generate an error. |
| 72 | + |
| 73 | +### Stop |
| 74 | + |
| 75 | +This operation MUST stop and delete a running container. |
| 76 | +Stopping a container MUST stop all of the processes running within the scope of the container. |
| 77 | +Deleting a container MUST delete the associated namespaces and cgroups for the container. |
| 78 | +Attempting to stop a container that is not running MUST have no effect on the container and MUST generate an error. |
| 79 | + |
| 80 | +### Pause |
| 81 | + |
| 82 | +This operation MUST suspend all processes that are running within the container. |
| 83 | +If the container is not running, either stopped or aleady paused, then this operation MUST have no effect on the container and MUST generate an error. |
| 84 | + |
| 85 | +### Unpause |
| 86 | + |
| 87 | +This operation MUST resume all processes that were previously paused via the `pause` operation. |
| 88 | +If the container is not paused then this operation MUST have no effect on the container and MUST generate an error. |
| 89 | + |
| 90 | +### Exec |
| 91 | + |
| 92 | +This operation MUST create a new process within the scope of the container. |
| 93 | +If the container is not running then this operation MUST have no effect on the container and MUST generate an error. |
| 94 | +Executing this operation multiple times MUST result in a new process each time. |
| 95 | +Unlike the container's main process which is specified in the `config.json` file, this specification does not define how the `exec` process is defined. |
| 96 | +The stopping, or exiting, of these secondary process MUST have no effect on the state of the container. |
| 97 | +In other words, a container (and its PID 1 process) MUST NOT be stopped due to the exiting of a secondary process. |
| 98 | + |
| 99 | +### Checkpoint |
| 100 | + |
| 101 | +This operation MUST create a checkpoint of a running container. |
| 102 | +If the container is not running then this operation MUST have no effect on the container and MUST generate an error. |
| 103 | +This specification does not specify how, or to where, the checkpoint data is persisted. |
| 104 | + |
| 105 | +OPEN: can we checkpoint a stopped container? |
| 106 | + |
| 107 | +OPEN: What's the state of the container afterwards? runc allows for the user to specify it. |
| 108 | + |
| 109 | +OPEN: we really should specify where to find the checkpoint info the same way we tell people where the state data is kept. |
| 110 | + |
| 111 | +### Restore |
| 112 | + |
| 113 | +This operation MUST restore a container to a previously created checkpoint state. |
| 114 | +This specification does not specify how, or from where, the checkpoint data is provided to the runtime. |
| 115 | + |
| 116 | +OPEN: what state must the container be in before they can do this? |
| 117 | + |
57 | 118 | ## Hooks |
58 | 119 |
|
59 | | -See [runtime configuration for hooks](./runtime-config.md) |
| 120 | +Many of the operations specified in this specification have "hooks" that allow for additional actions to be taken before or after each operation. |
| 121 | +See [runtime configuration for hooks](./runtime-config.md) for more information. |
0 commit comments