You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: runtime.md
+41-26Lines changed: 41 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,9 @@
2
2
3
3
## State
4
4
5
-
An OCI compliant 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.
5
+
The state of a container MUST include, at least, the following propeties:
6
+
7
+
***`ociVersion`**: (string) is the OCI specification version used when creating the container.
17
8
***`id`**: (string) is the container's ID.
18
9
This MUST be unique across all containers on this host.
19
10
There is no requirement that it be unique across hosts.
@@ -23,35 +14,34 @@ This allows the hooks to perform cleanup and teardown logic after the runtime de
23
14
***`bundlePath`**: (string) is the absolute path to the container's bundle directory.
24
15
This is provided so that consumers can find the container's configuration and root filesystem on the host.
25
16
26
-
*Example*
27
-
17
+
When serialized in JSON, the format MUST adhere to the following pattern:
28
18
```json
29
19
{
30
-
"version": "0.2.0",
31
-
"id": "oc-container",
20
+
"ociVersion": "0.2.0",
21
+
"id": "oci-container1",
32
22
"pid": 4422,
33
23
"bundlePath": "/containers/redis"
34
24
}
35
25
```
36
26
27
+
See [Query State](#query-state) for information on retrieving the state of a container.
28
+
37
29
## Lifecycle
38
30
The lifecycle describes the timeline of events that happen from when a container is created to when it ceases to exist.
39
31
40
32
1. OCI compliant runtime is invoked with a reference to the location of the bundle.
41
33
How this reference is passed to the runtime is an implementation detail.
42
34
2. The container's runtime environment MUST be created according to the configuration in `config.json` and `runtime.json`.
43
35
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.
36
+
3. The prestart hooks MUST be invoked by the runtime.
46
37
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.
38
+
4. The user specified process MUST be executed in the container.
39
+
5. The poststart hooks MUST be invoked by the runtime.
49
40
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.
41
+
6. Additional actions such as pausing the container, resuming the container or signaling the container MAY be performed using the runtime interface.
51
42
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.
43
+
7. The container MUST be destroyed by undoing the steps performed during create phase (step 2).
44
+
8. The poststop hooks MUST be invoked by the runtime and errors, if any, MAY be logged.
55
45
56
46
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.
57
47
@@ -63,9 +53,21 @@ OCI compliant runtimes MUST support the following operations, unless the operati
63
53
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
54
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
55
56
+
### Query State
57
+
58
+
`state <container-id>`
59
+
60
+
This operation MUST generate an error if it is not provided the ID of a container.
61
+
This operation MUST return the state of a container as specified in the [State](#state) section.
62
+
63
+
66
64
### Start
67
65
68
-
Using the data in `config.json` and `runtime.json` files this operation MUST create a new container.
66
+
`start <path-to-bundle> <container-id>`
67
+
68
+
This operation MUST generate an error if it is not provided a path to the bundle and the container ID to associate with the container.
69
+
If the ID provided is not unique across all containers running on this host, or is not valid in any other way, the implementation MUST generate an error.
70
+
Using the data in `config.json` and `runtime.json` files, that are in the bundle's directory, this operation MUST create a new container.
69
71
This includes creating the relevant namespaces, resource limits, etc and configuring the appropriate capabilities for the container.
70
72
A new process within the scope of the container MUST be created as specified by the `config.json` file.
71
73
The current working directory of the process MUST be set to the `cwd` field of the config.
@@ -75,27 +77,40 @@ Attempting to start an already running container MUST have no effect on the cont
75
77
76
78
### Stop
77
79
80
+
`stop <container-id>`
81
+
82
+
This operation MUST generate an error if it is not provided the container ID.
78
83
This operation MUST stop and delete a running container.
79
84
Stopping a container MUST stop all of the processes running within the scope of the container.
80
85
Deleting a container MUST delete the associated namespaces and resources associated with the container.
86
+
Once a container is deleted, its `id` MAY be used by subsequent containers.
81
87
Attempting to stop a container that is not running MUST have no effect on the container and MUST generate an error.
82
88
83
89
### Pause
84
90
91
+
`pause <container-id>`
92
+
93
+
This operation MUST generate an error if it is not provided the container ID.
85
94
This operation MUST suspend all processes that are running within the container.
86
95
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.
87
96
88
97
### Unpause
89
98
99
+
`unpause <container-id>`
100
+
101
+
This operation MUST generate an error if it is not provided the container ID.
90
102
This operation MUST resume all processes that were previously paused via the `pause` operation.
91
103
If the container is not paused then this operation MUST have no effect on the container and MUST generate an error.
92
104
93
105
### Exec
94
106
107
+
`exec <container-id> <path-to-json>`
108
+
109
+
This operation MUST generate an error if it is not provided the container ID and a path to the JSON describing the process to start.
95
110
This operation MUST create a new process within the scope of the container.
96
111
If the container is not running then this operation MUST have no effect on the container and MUST generate an error.
97
112
Executing this operation multiple times MUST result in a new process each time.
98
-
The specification of the new process MUST be done via a JSON encoded file matching the following format:
113
+
The JSON describing the new process MUST adhere to the following format:
0 commit comments