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
+39-31Lines changed: 39 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,21 +34,19 @@ See [Query State](#query-state) for information on retrieving the state of a con
34
34
## Lifecycle
35
35
The lifecycle describes the timeline of events that happen from when a container is created to when it ceases to exist.
36
36
37
-
1. OCI compliant runtimeis invoked with a reference to the location of the bundle.
38
-
How this reference is passed to the runtime is an implementation detail.
39
-
2. The container's runtime environment MUST be created according to the configuration in [`config.json`](config.md).
40
-
Any updates to `config.json` after container is running MUST not affect the container.
41
-
3. The prestart hooks MUST be invoked by the runtime.
42
-
If any prestart hook fails, then the container MUST be stopped and the lifecycle continues at step 8.
43
-
4. The user specified process MUST be executed in the container.
44
-
5. The poststart hooks MUST be invoked by the runtime.
45
-
If any poststart hook fails, then the container MUST be stopped and the lifecycle continues at step 8.
46
-
6. Additional actions such as pausing the container, resuming the container or signaling the container MAY be performed using the runtime interface.
37
+
1. OCI compliant runtime's `create` command is invoked with a reference to the location of the bundle and a unique identifier.
38
+
How these references are passed to the runtime is an implementation detail.
39
+
2. The container's runtime environment (namespaces, mounts, etc.) MUST be created according to the configuration in [`config.json`](config.md).
40
+
If a new PID namespace is requested in the [`config.json`](config.md), a PID namespace MUST created at this time.
41
+
However, the user-specified code (from ['process'](config.md#process-configuration)MUST NOT be executed at this time.
42
+
With the exception of the user-specified process, any updates to `config.json` after container is created MUST NOT affect the container.
43
+
3. Runtime's `start` command is invoked with the unique identifier of the container.
44
+
The runtime MUST create and start the user-specified code, as specified by [`process`](config.md#process-configuration), in the container's PID namespace.
45
+
Any updates to the user-specified code in ['process'](config.md#process-configuration) after this point MUST NOT have any effect on the container.
46
+
4. Additional actions such as pausing the container, resuming the container or signaling the container MAY be performed using the runtime interface.
47
47
The container MAY also error out, exit or crash.
48
-
7. The container MUST be destroyed by undoing the steps performed during create phase (step 2).
49
-
8. The poststop hooks MUST be invoked by the runtime and errors, if any, MAY be logged.
50
-
51
-
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.
48
+
5. Irrespective of how the user defined process stops (i.e. PID 1 exits), once the PID namespace is deleted the container MUST be destroyed by undoing the steps performed during create phase (step 2).
49
+
For clarity, all namespaces that were created in step 2 MUST be deleted.
52
50
53
51
## Operations
54
52
@@ -67,28 +65,43 @@ This operation MUST return the state of a container as specified in the [State](
67
65
In particular, the state MUST be serialized as JSON.
68
66
69
67
70
-
### Start
68
+
### Create
71
69
72
-
`start <container-id> <path-to-bundle>`
70
+
`create <container-id> <path-to-bundle>`
73
71
74
72
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.
75
-
If the ID provided is not unique across all containers within the scope of the runtime, or is not valid in any other way, the implementation MUST generate an error.
76
-
Using the data in `config.json`, that are in the bundle's directory, this operation MUST create a new container.
77
-
This includes creating the relevant namespaces, resource limits, etc and configuring the appropriate capabilities for the container.
78
-
A new process within the scope of the container MUST be created as specified by the `config.json` file otherwise an error MUST be generated.
73
+
If the ID provided is not unique across all containers within the scope of the runtime, or is not valid in any other way, the implementation MUST generate an error and a new container MUST not be created.
74
+
Using the data in [`config.json`](config.md), that is in the root of the bundle's directory, this operation MUST create a new container.
75
+
This includes creating, or entering, the namespaces specified in the [`config.json`](config.md), resource limits, etc and configuring the appropriate capabilities for the container.
76
+
If the `config.json` specifies that a PID namespace is to be created then one MUST be created, but the user-specified code within that namespace MUST NOT be created at this time.
77
+
In some implementations this means that a temporary process is created in the PID namespace but it pauses until the `start` operation is invoked before replacing the process with the user-specified code.
78
+
79
+
### Start
80
+
`start <container-id>`
79
81
80
-
Attempting to start an already running container MUST have no effect on the container and MUST generate an error.
82
+
This operation MUST generate an error if it is not provided the container ID.
83
+
This operation MUST create, and start, the user-specified code as specified by the [`process`](config.md#process-configuration) file otherwise an error MUST be generated and no process MUST be started.
84
+
This process MUST be run in the PID namespace associated with the container.
81
85
82
-
### Stop
86
+
Attempting to start an already started container MUST have no effect on the container and MUST generate an error.
83
87
84
-
`stop <container-id>`
88
+
### Run
89
+
`run <container-id>`
85
90
86
91
This operation MUST generate an error if it is not provided the container ID.
92
+
This operation MUST invoke the `create` operation, and if there are no errors, followed by the `start` operation.
93
+
94
+
### Delete
95
+
96
+
`delete <container-id>`
97
+
98
+
This operation MUST generate an error if it is not provided the container ID.
99
+
Attempting to delete a container that is not running, or that does not exist, MUST have no effect on the container and MUST generate an error.
87
100
This operation MUST stop and delete a running container.
88
101
Stopping a container MUST stop all of the processes running within the scope of the container.
89
-
Deleting a container MUST delete the associated namespaces and resources associated with the container.
102
+
Deleting a container MUST delete the namespaces, and resources, that were created during the `create` step.
103
+
Note that namespaces associated with the container but not created by this container MUST NOT be deleted.
90
104
Once a container is deleted, its `id` MAY be used by subsequent containers.
91
-
Attempting to stop a container that is not running MUST have no effect on the container and MUST generate an error.
92
105
93
106
### Exec
94
107
@@ -118,12 +131,7 @@ Example:
118
131
"cwd": "...",
119
132
}
120
133
```
121
-
This specification does not manadate the name of this JSON file.
134
+
This specification does not mandate the name of this JSON file.
122
135
See the specification of the `config.json` file for the definition of these fields.
123
136
The stopping, or exiting, of these secondary process MUST have no effect on the state of the container.
124
137
In other words, a container (and its PID 1 process) MUST NOT be stopped due to the exiting of a secondary process.
125
-
126
-
## Hooks
127
-
128
-
Many of the operations specified in this specification have "hooks" that allow for additional actions to be taken before or after each operation.
129
-
See [runtime configuration for hooks](./config.md#hooks) for more information.
0 commit comments