Skip to content

Latest commit

 

History

History
134 lines (97 loc) · 7.67 KB

File metadata and controls

134 lines (97 loc) · 7.67 KB
 
Jun 25, 2015
Jun 25, 2015
1
# Runtime and Lifecycle
Jun 6, 2015
Jun 6, 2015
2
Feb 22, 2016
Feb 22, 2016
3
## Scope of a Container
4
5
Barring access control concerns, the entity using a runtime to create a container MUST be able to use the operations defined in this specification against that same container.
6
Whether other entities using the same, or other, instance of the runtime can see that container is out of scope of this specification.
Sep 2, 2015
Sep 2, 2015
7
Feb 22, 2016
Feb 22, 2016
8
## State
Oct 5, 2015
Oct 5, 2015
9
Jan 22, 2017
Jan 22, 2017
10
The state of a container includes the following properties:
Oct 5, 2015
Oct 5, 2015
11
Jan 22, 2017
Jan 22, 2017
12
* **`ociVersion`** (string, REQUIRED) is the OCI specification version used when creating the container.
13
* **`id`** (string, REQUIRED) is the container's ID.
Oct 5, 2015
Oct 5, 2015
14
This MUST be unique across all containers on this host.
15
There is no requirement that it be unique across hosts.
Jan 22, 2017
Jan 22, 2017
16
* **`status`** (string, REQUIRED) is the runtime state of the container.
May 31, 2016
May 31, 2016
17
The value MAY be one of:
Jan 6, 2017
Jan 6, 2017
18
19
* `created`: the container process has neither exited nor executed the user-specified program
20
* `running`: the container process has executed the user-specified program but has not exited
21
* `stopped`: the container process has exited
May 31, 2016
May 31, 2016
22
Nov 3, 2016
Nov 3, 2016
23
Additional values MAY be defined by the runtime, however, they MUST be used to represent new runtime states not defined above.
Jan 22, 2017
Jan 22, 2017
24
* **`pid`** (int, REQUIRED when `status` is `created` or `running`) is the ID of the container process, as seen by the host.
25
* **`bundlePath`** (string, REQUIRED) is the absolute path to the container's bundle directory.
Oct 5, 2015
Oct 5, 2015
26
This is provided so that consumers can find the container's configuration and root filesystem on the host.
Jan 22, 2017
Jan 22, 2017
27
* **`annotations`** (map, OPTIONAL) contains the list of annotations associated with the container.
Jun 2, 2016
Jun 2, 2016
28
If no annotations were provided then this property MAY either be absent or an empty map.
Sep 2, 2015
Sep 2, 2015
29
Jan 22, 2017
Jan 22, 2017
30
The state MAY include additional properties.
31
Feb 22, 2016
Feb 22, 2016
32
When serialized in JSON, the format MUST adhere to the following pattern:
Apr 8, 2016
Apr 8, 2016
33
Sep 2, 2015
Sep 2, 2015
34
```json
35
{
Feb 22, 2016
Feb 22, 2016
36
"ociVersion": "0.2.0",
37
"id": "oci-container1",
May 31, 2016
May 31, 2016
38
"status": "running",
Sep 2, 2015
Sep 2, 2015
39
"pid": 4422,
Jun 2, 2016
Jun 2, 2016
40
"bundlePath": "/containers/redis",
41
"annotations": {
42
"myKey": "myValue"
43
}
Sep 2, 2015
Sep 2, 2015
44
}
45
```
46
Feb 22, 2016
Feb 22, 2016
47
See [Query State](#query-state) for information on retrieving the state of a container.
48
Jun 25, 2015
Jun 25, 2015
49
## Lifecycle
Dec 4, 2015
Dec 4, 2015
50
The lifecycle describes the timeline of events that happen from when a container is created to when it ceases to exist.
May 28, 2016
May 28, 2016
51
Oct 25, 2016
Oct 25, 2016
52
1. OCI compliant runtime's [`create`](runtime.md#create) command is invoked with a reference to the location of the bundle and a unique identifier.
Feb 22, 2016
Feb 22, 2016
53
2. The container's runtime environment MUST be created according to the configuration in [`config.json`](config.md).
Jun 3, 2016
Jun 3, 2016
54
If the runtime is unable to create the environment specified in the [`config.json`](config.md), it MUST generate an error.
Nov 18, 2016
Nov 18, 2016
55
While the resources requested in the [`config.json`](config.md) MUST be created, the user-specified program (from [`process`](config.md#process)) MUST NOT be run at this time.
Oct 25, 2016
Oct 25, 2016
56
Any updates to [`config.json`](config.md) after this step MUST NOT affect the container.
May 26, 2016
May 26, 2016
57
3. Once the container is created additional actions MAY be performed based on the features the runtime chooses to support.
May 31, 2016
May 31, 2016
58
However, some actions might only be available based on the current state of the container (e.g. only available while it is started).
Oct 25, 2016
Oct 25, 2016
59
4. Runtime's [`start`](runtime.md#start) command is invoked with the unique identifier of the container.
Nov 18, 2016
Nov 18, 2016
60
The runtime MUST run the user-specified program, as specified by [`process`](config.md#process).
Jan 6, 2017
Jan 6, 2017
61
5. The container process exits.
62
This MAY happen due to erroring out, exiting, crashing or the runtime's [`kill`](runtime.md#kill) operation being invoked.
Oct 25, 2016
Oct 25, 2016
63
6. Runtime's [`delete`](runtime.md#delete) command is invoked with the unique identifier of the container.
May 26, 2016
May 26, 2016
64
The container MUST be destroyed by undoing the steps performed during create phase (step 2).
Aug 3, 2015
Aug 3, 2015
65
May 23, 2016
May 23, 2016
66
## Errors
Feb 22, 2016
Feb 22, 2016
67
68
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.
69
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.
70
May 23, 2016
May 23, 2016
71
## Operations
72
73
OCI compliant runtimes MUST support the following operations, unless the operation is not supported by the base operating system.
74
Oct 25, 2016
Oct 25, 2016
75
Note: these operations are not specifying any command-line APIs, and the parameters are inputs for general operations.
May 24, 2016
May 24, 2016
76
Feb 22, 2016
Feb 22, 2016
77
### Query State
78
79
`state <container-id>`
80
81
This operation MUST generate an error if it is not provided the ID of a container.
May 26, 2016
May 26, 2016
82
Attempting to query a container that does not exist MUST generate an error.
Feb 22, 2016
Feb 22, 2016
83
This operation MUST return the state of a container as specified in the [State](#state) section.
84
May 26, 2016
May 26, 2016
85
### Create
Feb 22, 2016
Feb 22, 2016
86
May 26, 2016
May 26, 2016
87
`create <container-id> <path-to-bundle>`
Feb 22, 2016
Feb 22, 2016
88
89
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.
Sep 16, 2016
Sep 16, 2016
90
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.
May 26, 2016
May 26, 2016
91
Using the data in [`config.json`](config.md), this operation MUST create a new container.
Nov 18, 2016
Nov 18, 2016
92
This means that all of the resources associated with the container MUST be created, however, the user-specified program MUST NOT be run at this time.
Dec 7, 2016
Dec 7, 2016
93
If the runtime cannot create the container as specified in [`config.json`](config.md), it MUST generate an error and a new container MUST NOT be created.
May 31, 2016
May 31, 2016
94
95
Upon successful completion of this operation the `status` property of this container MUST be `created`.
Feb 22, 2016
Feb 22, 2016
96
May 2, 2016
May 2, 2016
97
The runtime MAY validate `config.json` against this spec, either generically or with respect to the local system capabilities, before creating the container ([step 2](#lifecycle)).
May 26, 2016
May 26, 2016
98
Runtime callers who are interested in pre-create validation can run [bundle-validation tools](implementations.md#testing--tools) before invoking the create operation.
99
100
Any changes made to the [`config.json`](config.md) file after this operation will not have an effect on the container.
101
102
### Start
103
`start <container-id>`
May 2, 2016
May 2, 2016
104
May 26, 2016
May 26, 2016
105
This operation MUST generate an error if it is not provided the container ID.
106
Attempting to start a container that does not exist MUST generate an error.
107
Attempting to start an already started container MUST have no effect on the container and MUST generate an error.
Nov 18, 2016
Nov 18, 2016
108
This operation MUST run the user-specified program as specified by [`process`](config.md#process).
May 26, 2016
May 26, 2016
109
May 31, 2016
May 31, 2016
110
Upon successful completion of this operation the `status` property of this container MUST be `running`.
111
May 26, 2016
May 26, 2016
112
### Kill
113
`kill <container-id> <signal>`
Feb 22, 2016
Feb 22, 2016
114
May 26, 2016
May 26, 2016
115
This operation MUST generate an error if it is not provided the container ID.
116
Attempting to send a signal to a container that is not running MUST have no effect on the container and MUST generate an error.
117
This operation MUST send the specified signal to the process in the container.
Feb 22, 2016
Feb 22, 2016
118
May 31, 2016
May 31, 2016
119
When the process in the container is stopped, irrespective of it being as a result of a `kill` operation or any other reason, the `status` property of this container MUST be `stopped`.
120
May 26, 2016
May 26, 2016
121
### Delete
122
`delete <container-id>`
Feb 22, 2016
Feb 22, 2016
123
124
This operation MUST generate an error if it is not provided the container ID.
May 26, 2016
May 26, 2016
125
Attempting to delete a container that does not exist MUST generate an error.
126
Attempting to delete a container whose process is still running MUST generate an error.
127
Deleting a container MUST delete the resources that were created during the `create` step.
128
Note that resources associated with the container, but not created by this container, MUST NOT be deleted.
129
Once a container is deleted its ID MAY be used by a subsequent container.
Feb 22, 2016
Feb 22, 2016
130
Sep 9, 2015
Sep 9, 2015
131
May 26, 2016
May 26, 2016
132
## Hooks
Feb 22, 2016
Feb 22, 2016
133
Many of the operations specified in this specification have "hooks" that allow for additional actions to be taken before or after each operation.
134
See [runtime configuration for hooks](./config.md#hooks) for more information.