Skip to content

Commit 82cfe56

Browse files
committed
Merge pull request opencontainers#231 from mrunalp/lifecycle
Add lifecycle for containers
2 parents 58f6cab + 7713efc commit 82cfe56

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

runtime.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,24 @@ This is provided so that consumers can find the container's configuration and ro
3535
```
3636

3737
## Lifecycle
38-
39-
### Create
40-
41-
Creates the container: file system, namespaces, cgroups, capabilities.
42-
43-
### Start (process)
44-
45-
Runs a process in a container.
46-
Can be invoked several times.
47-
48-
### Stop (process)
49-
50-
Not sure we need that from runc cli.
51-
Process is killed from the outside.
52-
53-
This event needs to be captured by runc to run onstop event handlers.
38+
The lifecycle describes the timeline of events that happen from when a container is created to when it ceases to exist.
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.
42+
Any updates to config.json after container is running do not affect the container.
43+
3. The container's state.json file is written to the filesystem under /run/opencontainer/<runtime>/containers/<id>/.
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.
54+
55+
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.
5456

5557
## Hooks
5658

0 commit comments

Comments
 (0)