Skip to content

Latest commit

 

History

History
860 lines (763 loc) · 30.4 KB

File metadata and controls

860 lines (763 loc) · 30.4 KB
 
Mar 2, 2017
Mar 2, 2017
1
# <a name="containerConfigurationFile" />Container Configuration file
Jun 25, 2015
Jun 25, 2015
2
May 13, 2017
May 13, 2017
3
This configuration file contains metadata necessary to implement [standard operations](runtime.md#operations) against the container.
May 9, 2017
May 9, 2017
4
This includes the process to run, environment variables to inject, sandboxing features to use, etc.
5
Jul 19, 2016
Jul 19, 2016
6
The canonical schema is defined in this document, but there is a JSON Schema in [`schema/config-schema.json`](schema/config-schema.json) and Go bindings in [`specs-go/config.go`](specs-go/config.go).
Feb 8, 2017
Feb 8, 2017
7
[Platform](spec.md#platforms)-specific configuration schema are defined in the [platform-specific documents](#platform-specific-configuration) linked below.
8
For properties that are only defined for some [platforms](spec.md#platforms), the Go property has a `platform` tag listing those protocols (e.g. `platform:"linux,solaris"`).
Jun 25, 2015
Jun 25, 2015
9
Feb 7, 2017
Feb 7, 2017
10
Below is a detailed description of each field defined in the configuration format and valid values are specified.
11
Platform-specific fields are identified as such.
12
For all platform-specific configuration values, the scope defined below in the [Platform-specific configuration](#platform-specific-configuration) section applies.
13
Jun 25, 2015
Jun 25, 2015
14
Mar 2, 2017
Mar 2, 2017
15
## <a name="configSpecificationVersion" />Specification version
Jun 25, 2015
Jun 25, 2015
16
Mar 3, 2017
Mar 3, 2017
17
* **`ociVersion`** (string, REQUIRED) MUST be in [SemVer v2.0.0][semver-v2.0.0] format and specifies the version of the Open Container Runtime Specification with which the bundle complies.
Jun 1, 2017
Jun 1, 2017
18
The Open Container Runtime Specification follows semantic versioning and retains forward and backward compatibility within major versions.
19
For example, if a configuration is compliant with version 1.1 of this specification, it is compatible with all runtimes that support any 1.1 or later release of this specification, but is not compatible with a runtime that supports 1.0 and not 1.1.
Jun 25, 2015
Jun 25, 2015
20
Apr 8, 2016
Apr 8, 2016
21
### Example
Jun 30, 2015
Jun 30, 2015
22
Jun 29, 2015
Jun 29, 2015
23
```json
Jan 15, 2016
Jan 15, 2016
24
"ociVersion": "0.1.0"
Jun 25, 2015
Jun 25, 2015
25
```
26
Mar 2, 2017
Mar 2, 2017
27
## <a name="configRoot" />Root
Jun 25, 2015
Jun 25, 2015
28
Jun 16, 2017
Jun 16, 2017
29
**`root`** (object, OPTIONAL) specifies the container's root filesystem.
30
On Windows, for Windows Server Containers, this field is REQUIRED.
31
For [Hyper-V Containers](config-windows.md#hyperv), this field MUST NOT be set.
Jul 1, 2015
Jul 1, 2015
32
Jun 16, 2017
Jun 16, 2017
33
On all other platforms, this field is REQUIRED.
May 15, 2017
May 15, 2017
34
Jun 16, 2017
Jun 16, 2017
35
* **`path`** (string, REQUIRED) Specifies the path to the root filesystem for the container.
36
37
* On Windows, `path` MUST be a [volume GUID path][naming-a-volume].
38
Jun 21, 2017
Jun 21, 2017
39
* On POSIX platforms, `path` is either an absolute path or a relative path to the bundle.
Jun 16, 2017
Jun 16, 2017
40
For example, with a bundle at `/to/bundle` and a root filesystem at `/to/bundle/rootfs`, the `path` value can be either `/to/bundle/rootfs` or `rootfs`.
Jun 1, 2017
Jun 1, 2017
41
The value SHOULD be the conventional `rootfs`.
May 15, 2017
May 15, 2017
42
Jun 16, 2017
Jun 16, 2017
43
A directory MUST exist at the path declared by the field.
44
Jun 1, 2017
Jun 1, 2017
45
* **`readonly`** (bool, OPTIONAL) If true then the root filesystem MUST be read-only inside the container, defaults to false.
Jun 1, 2017
Jun 1, 2017
46
* On Windows, this field MUST be omitted or false.
Jun 25, 2015
Jun 25, 2015
47
Jun 21, 2017
Jun 21, 2017
48
### Example (POSIX platforms)
Jun 30, 2015
Jun 30, 2015
49
Jun 29, 2015
Jun 29, 2015
50
```json
Jun 30, 2015
Jun 30, 2015
51
"root": {
52
"path": "rootfs",
53
"readonly": true
54
}
Jun 25, 2015
Jun 25, 2015
55
```
56
May 24, 2017
May 24, 2017
57
### Example (Windows)
58
59
```json
60
"root": {
61
"path": "\\\\?\\Volume{ec84d99e-3f02-11e7-ac6c-00155d7682cf}\\"
62
}
63
```
64
Mar 2, 2017
Mar 2, 2017
65
## <a name="configMounts" />Mounts
Sep 3, 2015
Sep 3, 2015
66
Mar 29, 2017
Mar 29, 2017
67
**`mounts`** (array of objects, OPTIONAL) specifies additional mounts beyond [`root`](#root).
Jun 1, 2017
Jun 1, 2017
68
The runtime MUST mount entries in the listed order.
69
For Linux, the parameters are as documented in [mount(2)][mount.2] system call man page.
70
For Solaris, the mount entry corresponds to the 'fs' resource in the [zonecfg(1M)][zonecfg.1m] man page.
Feb 7, 2017
Feb 7, 2017
71
Sep 18, 2016
Sep 18, 2016
72
* **`destination`** (string, REQUIRED) Destination of mount point: path inside container.
Jun 1, 2017
Jun 1, 2017
73
This value MUST be an absolute path.
74
* Windows: one mount destination MUST NOT be nested within another mount (e.g., c:\\foo and c:\\foo\\bar).
75
* Solaris: corresponds to "dir" of the fs resource in [zonecfg(1M)][zonecfg.1m].
Feb 28, 2017
Feb 28, 2017
76
* **`source`** (string, OPTIONAL) A device name, but can also be a directory name or a dummy.
Jun 1, 2017
Jun 1, 2017
77
Path values are either absolute or relative to the bundle.
Jun 1, 2017
Jun 1, 2017
78
* Windows: a local directory on the filesystem of the container host. UNC paths and mapped drives are not supported.
79
* Solaris: corresponds to "special" of the fs resource in [zonecfg(1M)][zonecfg.1m].
May 17, 2017
May 17, 2017
80
* **`options`** (array of strings, OPTIONAL) Mount options of the filesystem to be used.
Jun 1, 2017
Jun 1, 2017
81
* Linux: supported options are listed in the [mount(8)][mount.8] man page.
82
Note both [filesystem-independent][mount.8-filesystem-independent] and [filesystem-specific][mount.8-filesystem-specific] options are listed.
Jun 1, 2017
Jun 1, 2017
83
* Solaris: corresponds to "options" of the fs resource in [zonecfg(1M)][zonecfg.1m].
Jun 23, 2017
Jun 23, 2017
84
* Windows: runtimes MUST support `ro`, mounting the filesystem read-only when `ro` is given.
Sep 3, 2015
Sep 3, 2015
85
Jun 1, 2017
Jun 1, 2017
86
### Example (Windows)
87
88
```json
89
"mounts": [
90
{
91
"destination": "C:\\folder-inside-container",
92
"source": "C:\\folder-on-host",
Jun 23, 2017
Jun 23, 2017
93
"options": ["ro"]
Jun 1, 2017
Jun 1, 2017
94
}
95
]
96
```
97
Jun 21, 2017
Jun 21, 2017
98
### <a name="configPOSIXMounts" />POSIX-platform Mounts
Jun 1, 2017
Jun 1, 2017
99
Jun 21, 2017
Jun 21, 2017
100
For POSIX platforms the `mounts` structure has the following fields:
Jun 1, 2017
Jun 1, 2017
101
102
* **`type`** (string, OPTIONAL) The type of the filesystem to be mounted.
103
* Linux: filesystem types supported by the kernel as listed in */proc/filesystems* (e.g., "minix", "ext2", "ext3", "jfs", "xfs", "reiserfs", "msdos", "proc", "nfs", "iso9660").
104
* Solaris: corresponds to "type" of the fs resource in [zonecfg(1M)][zonecfg.1m].
105
Apr 8, 2016
Apr 8, 2016
106
### Example (Linux)
Sep 3, 2015
Sep 3, 2015
107
108
```json
109
"mounts": [
110
{
Jan 27, 2016
Jan 27, 2016
111
"destination": "/tmp",
112
"type": "tmpfs",
113
"source": "tmpfs",
114
"options": ["nosuid","strictatime","mode=755","size=65536k"]
Sep 3, 2015
Sep 3, 2015
115
},
116
{
Jan 27, 2016
Jan 27, 2016
117
"destination": "/data",
118
"type": "bind",
119
"source": "/volumes/testing",
120
"options": ["rbind","rw"]
Sep 3, 2015
Sep 3, 2015
121
}
122
]
123
```
124
Oct 12, 2016
Oct 12, 2016
125
### Example (Solaris)
126
127
```json
128
"mounts": [
129
{
130
"destination": "/opt/local",
131
"type": "lofs",
132
"source": "/usr/local",
133
"options": ["ro","nodevices"]
134
},
135
{
136
"destination": "/opt/sfw",
137
"type": "lofs",
138
"source": "/opt/sfw"
139
}
140
]
141
```
142
Mar 2, 2017
Mar 2, 2017
143
## <a name="configProcess" />Process
Jun 25, 2015
Jun 25, 2015
144
Feb 27, 2017
Feb 27, 2017
145
**`process`** (object, OPTIONAL) specifies the container process.
Jun 1, 2017
Jun 1, 2017
146
This property is REQUIRED when [`start`](runtime.md#start) is called.
Aug 3, 2016
Aug 3, 2016
147
Jun 2, 2017
Jun 2, 2017
148
* **`terminal`** (bool, OPTIONAL) specifies whether a terminal is attached to the process, defaults to false.
149
As an example, if set to true on Linux a pseudoterminal pair is allocated for the process and the pseudoterminal slave is duplicated on the process's [standard streams][stdin.3].
Jun 1, 2017
Jun 1, 2017
150
* **`consoleSize`** (object, OPTIONAL) specifies the console size in characters of the terminal.
151
Runtimes MUST ignore `consoleSize` if `terminal` is `false` or unset.
May 11, 2017
May 11, 2017
152
* **`height`** (uint, REQUIRED)
153
* **`width`** (uint, REQUIRED)
Sep 18, 2016
Sep 18, 2016
154
* **`cwd`** (string, REQUIRED) is the working directory that will be set for the executable.
Jun 1, 2017
Jun 1, 2017
155
This value MUST be an absolute path.
Jun 1, 2017
Jun 1, 2017
156
* **`env`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2008's `environ`][ieee-1003.1-2008-xbd-c8.1].
157
* **`args`** (array of strings, REQUIRED) with similar semantics to [IEEE Std 1003.1-2008 `execvp`'s *argv*][ieee-1003.1-2008-xsh-exec].
Jun 1, 2017
Jun 1, 2017
158
This specification extends the IEEE standard in that at least one entry is REQUIRED, and that entry is used with the same semantics as `execvp`'s *file*.
Jul 5, 2017
Jul 5, 2017
159
Jul 5, 2017
Jul 5, 2017
160
### <a name="configPOSIXProcess" />POSIX process
Jul 5, 2017
Jul 5, 2017
161
Jul 5, 2017
Jul 5, 2017
162
For systems that support POSIX rlimits (for example Linux and Solaris), the `process` object supports the following process-specific properties:
Jul 5, 2017
Jul 5, 2017
163
Jun 2, 2017
Jun 2, 2017
164
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for the process.
Jun 1, 2017
Jun 1, 2017
165
Each entry has the following structure:
Nov 3, 2016
Nov 3, 2016
166
Jul 5, 2017
Jul 5, 2017
167
* **`type`** (string, REQUIRED) the platform resource being limited.
168
* Linux: valid values are defined in the [`getrlimit(2)`][getrlimit.2] man page, such as `RLIMIT_MSGQUEUE`.
169
* Solaris: valid values are defined in the [`getrlimit(3)`][getrlimit.3] man page, such as `RLIMIT_CORE`.
170
171
The runtime MUST [generate an error](runtime.md#errors) for any values which cannot be mapped to a relevant kernel interface
172
For each entry in `rlimits`, a [`getrlimit(3)`][getrlimit.3] on `type` MUST succeed.
173
For the following properties, `rlim` refers to the status returned by the `getrlimit(3)` call.
174
175
* **`soft`** (uint64, REQUIRED) the value of the limit enforced for the corresponding resource.
176
`rlim.rlim_cur` MUST match the configured value.
177
* **`hard`** (uint64, REQUIRED) the ceiling for the soft limit that could be set by an unprivileged process.
178
`rlim.rlim_max` MUST match the configured value.
179
Only a privileged process (e.g. one with the `CAP_SYS_RESOURCE` capability) can raise a hard limit.
180
181
If `rlimits` contains duplicated entries with same `type`, the runtime MUST [generate an error](runtime.md#errors).
Nov 3, 2016
Nov 3, 2016
182
Jul 5, 2017
Jul 5, 2017
183
### <a name="configLinuxProcess" />Linux Process
Nov 3, 2016
Nov 3, 2016
184
Jul 5, 2017
Jul 5, 2017
185
For Linux-based systems, the `process` object supports the following process-specific properties.
Feb 7, 2017
Feb 7, 2017
186
Jun 2, 2017
Jun 2, 2017
187
* **`apparmorProfile`** (string, OPTIONAL) specifies the name of the AppArmor profile for the process.
Jun 1, 2017
Jun 1, 2017
188
For more information about AppArmor, see [AppArmor documentation][apparmor].
Jul 5, 2017
Jul 5, 2017
189
* **`capabilities`** (object, OPTIONAL) is an object containing arrays that specifies the sets of capabilities for the process.
190
Valid values are defined in the [capabilities(7)][capabilities.7] man page, such as `CAP_CHOWN`.
191
Any value which cannot be mapped to a relevant kernel interface MUST cause an error.
192
`capabilities` contains the following properties:
193
194
* **`effective`** (array of strings, OPTIONAL) the `effective` field is an array of effective capabilities that are kept for the process.
195
* **`bounding`** (array of strings, OPTIONAL) the `bounding` field is an array of bounding capabilities that are kept for the process.
196
* **`inheritable`** (array of strings, OPTIONAL) the `inheritable` field is an array of inheritable capabilities that are kept for the process.
197
* **`permitted`** (array of strings, OPTIONAL) the `permitted` field is an array of permitted capabilities that are kept for the process.
198
* **`ambient`** (array of strings, OPTIONAL) the `ambient` field is an array of ambient capabilities that are kept for the process.
199
* **`noNewPrivileges`** (bool, OPTIONAL) setting `noNewPrivileges` to true prevents the process from gaining additional privileges.
200
As an example, the [`no_new_privs`][no-new-privs] article in the kernel documentation has information on how this is achieved using a `prctl` system call on Linux.
Jun 2, 2017
Jun 2, 2017
201
* **`oomScoreAdj`** *(int, OPTIONAL)* adjusts the oom-killer score in `[pid]/oom_score_adj` for the process's `[pid]` in a [proc pseudo-filesystem][procfs].
May 9, 2017
May 9, 2017
202
If `oomScoreAdj` is set, the runtime MUST set `oom_score_adj` to the given value.
203
If `oomScoreAdj` is not set, the runtime MUST NOT change the value of `oom_score_adj`.
204
205
This is a per-process setting, where as [`disableOOMKiller`](config-linux.md#disable-out-of-memory-killer) is scoped for a memory cgroup.
206
For more information on how these two settings work together, see [the memory cgroup documentation section 10. OOM Contol][cgroup-v1-memory_2].
Jun 2, 2017
Jun 2, 2017
207
* **`selinuxLabel`** (string, OPTIONAL) specifies the SELinux label for the process.
Jun 1, 2017
Jun 1, 2017
208
For more information about SELinux, see [SELinux documentation][selinux].
Mar 2, 2016
Mar 2, 2016
209
Mar 2, 2017
Mar 2, 2017
210
### <a name="configUser" />User
Mar 17, 2016
Mar 17, 2016
211
Jul 1, 2015
Jul 1, 2015
212
The user for the process is a platform-specific structure that allows specific control over which user the process runs as.
Mar 17, 2016
Mar 17, 2016
213
Jun 21, 2017
Jun 21, 2017
214
#### <a name="configPOSIXUser" />POSIX-platform User
Mar 17, 2016
Mar 17, 2016
215
Jun 21, 2017
Jun 21, 2017
216
For POSIX platforms the `user` structure has the following fields:
Jun 30, 2015
Jun 30, 2015
217
Mar 3, 2017
Mar 3, 2017
218
* **`uid`** (int, REQUIRED) specifies the user ID in the [container namespace](glossary.md#container-namespace).
219
* **`gid`** (int, REQUIRED) specifies the group ID in the [container namespace](glossary.md#container-namespace).
Jun 1, 2017
Jun 1, 2017
220
* **`additionalGids`** (array of ints, OPTIONAL) specifies additional group IDs in the [container namespace](glossary.md#container-namespace) to be added to the process.
Jun 30, 2015
Jun 30, 2015
221
Mar 17, 2016
Mar 17, 2016
222
_Note: symbolic name for uid and gid, such as uname and gname respectively, are left to upper levels to derive (i.e. `/etc/passwd` parsing, NSS, etc)_
223
Apr 8, 2016
Apr 8, 2016
224
### Example (Linux)
Jun 30, 2015
Jun 30, 2015
225
Jun 29, 2015
Jun 29, 2015
226
```json
Jun 30, 2015
Jun 30, 2015
227
"process": {
228
"terminal": true,
Sep 20, 2016
Sep 20, 2016
229
"consoleSize": {
230
"height": 25,
231
"width": 80
232
},
Jun 30, 2015
Jun 30, 2015
233
"user": {
234
"uid": 1,
235
"gid": 1,
Aug 29, 2015
Aug 29, 2015
236
"additionalGids": [5, 6]
Jun 30, 2015
Jun 30, 2015
237
},
Jun 30, 2015
Jun 30, 2015
238
"env": [
239
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
240
"TERM=xterm"
241
],
Aug 29, 2015
Aug 29, 2015
242
"cwd": "/root",
Jun 30, 2015
Jun 30, 2015
243
"args": [
244
"sh"
Mar 2, 2016
Mar 2, 2016
245
],
Mar 2, 2016
Mar 2, 2016
246
"apparmorProfile": "acme_secure_profile",
247
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
Mar 2, 2016
Mar 2, 2016
248
"noNewPrivileges": true,
Feb 22, 2017
Feb 22, 2017
249
"capabilities": {
250
"bounding": [
251
"CAP_AUDIT_WRITE",
252
"CAP_KILL",
253
"CAP_NET_BIND_SERVICE"
254
],
255
"permitted": [
256
"CAP_AUDIT_WRITE",
257
"CAP_KILL",
258
"CAP_NET_BIND_SERVICE"
259
],
260
"inheritable": [
261
"CAP_AUDIT_WRITE",
262
"CAP_KILL",
263
"CAP_NET_BIND_SERVICE"
264
],
265
"effective": [
266
"CAP_AUDIT_WRITE",
Mar 6, 2017
Mar 6, 2017
267
"CAP_KILL"
Feb 22, 2017
Feb 22, 2017
268
],
269
"ambient": [
270
"CAP_NET_BIND_SERVICE"
271
]
272
},
Mar 10, 2016
Mar 10, 2016
273
"rlimits": [
274
{
275
"type": "RLIMIT_NOFILE",
276
"hard": 1024,
277
"soft": 1024
278
}
Jun 30, 2015
Jun 30, 2015
279
]
280
}
Jun 25, 2015
Jun 25, 2015
281
```
May 4, 2016
May 4, 2016
282
### Example (Solaris)
283
284
```json
285
"process": {
286
"terminal": true,
Sep 20, 2016
Sep 20, 2016
287
"consoleSize": {
288
"height": 25,
289
"width": 80
290
},
May 4, 2016
May 4, 2016
291
"user": {
292
"uid": 1,
293
"gid": 1,
294
"additionalGids": [2, 8]
295
},
296
"env": [
297
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
298
"TERM=xterm"
299
],
300
"cwd": "/root",
301
"args": [
302
"/usr/bin/bash"
Sep 14, 2016
Sep 14, 2016
303
]
304
}
305
```
306
Mar 2, 2017
Mar 2, 2017
307
#### <a name="configWindowsUser" />Windows User
Sep 14, 2016
Sep 14, 2016
308
309
For Windows based systems the user structure has the following fields:
310
Sep 18, 2016
Sep 18, 2016
311
* **`username`** (string, OPTIONAL) specifies the user name for the process.
Sep 14, 2016
Sep 14, 2016
312
313
### Example (Windows)
314
315
```json
316
"process": {
317
"terminal": true,
318
"user": {
319
"username": "containeradministrator"
320
},
321
"env": [
322
"VARIABLE=1"
May 4, 2016
May 4, 2016
323
],
Sep 14, 2016
Sep 14, 2016
324
"cwd": "c:\\foo",
325
"args": [
326
"someapp.exe",
327
]
May 4, 2016
May 4, 2016
328
}
329
```
Jun 25, 2015
Jun 25, 2015
330
331
Mar 2, 2017
Mar 2, 2017
332
## <a name="configHostname" />Hostname
Jun 25, 2015
Jun 25, 2015
333
Feb 7, 2017
Feb 7, 2017
334
* **`hostname`** (string, OPTIONAL) specifies the container's hostname as seen by processes running inside the container.
Jun 1, 2017
Jun 1, 2017
335
On Linux, for example, this will change the hostname in the [container](glossary.md#container-namespace) [UTS namespace][uts-namespace.7].
336
Depending on your [namespace configuration](config-linux.md#namespaces), the container UTS namespace may be the [runtime](glossary.md#runtime-namespace) [UTS namespace][uts-namespace.7].
Jun 25, 2015
Jun 25, 2015
337
Apr 8, 2016
Apr 8, 2016
338
### Example
Jun 30, 2015
Jun 30, 2015
339
Jun 29, 2015
Jun 29, 2015
340
```json
Jun 30, 2015
Jun 30, 2015
341
"hostname": "mrsdalloway"
Jun 25, 2015
Jun 25, 2015
342
```
343
Mar 2, 2017
Mar 2, 2017
344
## <a name="configPlatformSpecificConfiguration" />Platform-specific configuration
May 2, 2016
May 2, 2016
345
Sep 18, 2016
Sep 18, 2016
346
* **`linux`** (object, OPTIONAL) [Linux-specific configuration](config-linux.md).
Jun 16, 2017
Jun 16, 2017
347
This MAY be set if the target platform of this spec is `linux`.
Nov 14, 2016
Nov 14, 2016
348
* **`windows`** (object, OPTIONAL) [Windows-specific configuration](config-windows.md).
Jun 16, 2017
Jun 16, 2017
349
This MUST be set if the target platform of this spec is `windows`.
Feb 7, 2017
Feb 7, 2017
350
* **`solaris`** (object, OPTIONAL) [Solaris-specific configuration](config-solaris.md).
Jun 16, 2017
Jun 16, 2017
351
This MAY be set if the target platform of this spec is `solaris`.
May 2, 2016
May 2, 2016
352
353
### Example (Linux)
354
355
```json
356
{
357
"linux": {
358
"namespaces": [
Jun 1, 2017
Jun 1, 2017
359
{
360
"type": "pid"
361
}
May 2, 2016
May 2, 2016
362
]
363
}
364
}
365
```
Oct 6, 2015
Oct 6, 2015
366
Jun 21, 2017
Jun 21, 2017
367
## <a name="configHooks" />POSIX-platform Hooks
Jan 27, 2016
Jan 27, 2016
368
Jun 21, 2017
Jun 21, 2017
369
For POSIX platforms, the configuration structure supports `hooks` for configuring custom actions related to the [lifecycle](runtime.md#lifecycle) of the container.
Jan 27, 2016
Jan 27, 2016
370
Jan 4, 2017
Jan 4, 2017
371
* **`hooks`** (object, OPTIONAL) MAY contain any of the following properties:
May 11, 2017
May 11, 2017
372
* **`prestart`** (array of objects, OPTIONAL) is an array of [pre-start hooks](#prestart).
373
Entries in the array contain the following properties:
Jun 1, 2017
Jun 1, 2017
374
* **`path`** (string, REQUIRED) with similar semantics to [IEEE Std 1003.1-2008 `execv`'s *path*][ieee-1003.1-2008-functions-exec].
May 11, 2017
May 11, 2017
375
This specification extends the IEEE standard in that **`path`** MUST be absolute.
Jun 1, 2017
Jun 1, 2017
376
* **`args`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2008 `execv`'s *argv*][ieee-1003.1-2008-functions-exec].
377
* **`env`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2008's `environ`][ieee-1003.1-2008-xbd-c8.1].
May 11, 2017
May 11, 2017
378
* **`timeout`** (int, OPTIONAL) is the number of seconds before aborting the hook.
379
If set, `timeout` MUST be greater than zero.
380
* **`poststart`** (array of objects, OPTIONAL) is an array of [post-start hooks](#poststart).
381
Entries in the array have the same schema as pre-start entries.
382
* **`poststop`** (array of objects, OPTIONAL) is an array of [post-stop hooks](#poststop).
383
Entries in the array have the same schema as pre-start entries.
Jan 27, 2016
Jan 27, 2016
384
Feb 7, 2017
Feb 7, 2017
385
Hooks allow users to specify programs to run before or after various lifecycle events.
Jan 27, 2016
Jan 27, 2016
386
Hooks MUST be called in the listed order.
Feb 7, 2017
Feb 7, 2017
387
The [state](runtime.md#state) of the container MUST be passed to hooks over stdin so that they may do work appropriate to the current state of the container.
Jan 27, 2016
Jan 27, 2016
388
Mar 2, 2017
Mar 2, 2017
389
### <a name="configHooksPrestart" />Prestart
Jan 27, 2016
Jan 27, 2016
390
Mar 3, 2017
Mar 3, 2017
391
The pre-start hooks MUST be called after the [`start`](runtime.md#start) operation is called but [before the user-specified program command is executed](runtime.md#lifecycle).
Feb 7, 2017
Feb 7, 2017
392
On Linux, for example, they are called after the container namespaces are created, so they provide an opportunity to customize the container (e.g. the network namespace could be specified in this hook).
Jan 27, 2016
Jan 27, 2016
393
Mar 2, 2017
Mar 2, 2017
394
### <a name="configHooksPoststart" />Poststart
Jan 27, 2016
Jan 27, 2016
395
May 12, 2017
May 12, 2017
396
The post-start hooks MUST be called [after the user-specified process is executed](runtime.md#lifecycle) but before the [`start`](runtime.md#start) operation returns.
Feb 7, 2017
Feb 7, 2017
397
For example, this hook can notify the user that the container process is spawned.
Jan 27, 2016
Jan 27, 2016
398
Mar 2, 2017
Mar 2, 2017
399
### <a name="configHooksPoststop" />Poststop
Jan 27, 2016
Jan 27, 2016
400
May 12, 2017
May 12, 2017
401
The post-stop hooks MUST be called [after the container is deleted](runtime.md#lifecycle) but before the [`delete`](runtime.md#delete) operation returns.
Feb 7, 2017
Feb 7, 2017
402
Cleanup or debugging functions are examples of such a hook.
Jan 27, 2016
Jan 27, 2016
403
Apr 8, 2016
Apr 8, 2016
404
### Example
Jan 27, 2016
Jan 27, 2016
405
406
```json
Sep 7, 2016
Sep 7, 2016
407
"hooks": {
Jan 27, 2016
Jan 27, 2016
408
"prestart": [
409
{
410
"path": "/usr/bin/fix-mounts",
411
"args": ["fix-mounts", "arg1", "arg2"],
412
"env": [ "key1=value1"]
413
},
414
{
415
"path": "/usr/bin/setup-network"
416
}
417
],
418
"poststart": [
419
{
Apr 11, 2016
Apr 11, 2016
420
"path": "/usr/bin/notify-start",
Mar 16, 2016
Mar 16, 2016
421
"timeout": 5
Jan 27, 2016
Jan 27, 2016
422
}
423
],
424
"poststop": [
425
{
426
"path": "/usr/sbin/cleanup.sh",
427
"args": ["cleanup.sh", "-f"]
428
}
429
]
430
}
431
```
432
Mar 2, 2017
Mar 2, 2017
433
## <a name="configAnnotations" />Annotations
Mar 9, 2016
Mar 9, 2016
434
Sep 18, 2016
Sep 18, 2016
435
**`annotations`** (object, OPTIONAL) contains arbitrary metadata for the container.
Jun 1, 2017
Jun 1, 2017
436
This information MAY be structured or unstructured.
437
Annotations MUST be a key-value map.
438
If there are no annotations then this property MAY either be absent or an empty map.
Jan 13, 2017
Jan 13, 2017
439
Jun 1, 2017
Jun 1, 2017
440
Keys MUST be strings.
441
Keys MUST NOT be an empty string.
442
Keys SHOULD be named using a reverse domain notation - e.g. `com.example.myKey`.
443
Keys using the `org.opencontainers` namespace are reserved and MUST NOT be used by subsequent specifications.
444
Implementations that are reading/processing this configuration file MUST NOT generate an error if they encounter an unknown annotation key.
Mar 9, 2016
Mar 9, 2016
445
Jun 1, 2017
Jun 1, 2017
446
Values MUST be strings.
447
Values MAY be an empty string.
Jan 13, 2017
Jan 13, 2017
448
Mar 9, 2016
Mar 9, 2016
449
```json
450
"annotations": {
Sep 7, 2016
Sep 7, 2016
451
"com.example.gpu-cores": "2"
Mar 9, 2016
Mar 9, 2016
452
}
453
```
454
Mar 2, 2017
Mar 2, 2017
455
## <a name="configExtensibility" />Extensibility
Jun 1, 2017
Jun 1, 2017
456
Jun 1, 2017
Jun 1, 2017
457
Runtimes that are reading or processing this configuration file MUST NOT generate an error if they encounter an unknown property.
Sep 2, 2016
Sep 2, 2016
458
Instead they MUST ignore unknown properties.
459
Feb 7, 2017
Feb 7, 2017
460
## Valid values
461
Jun 1, 2017
Jun 1, 2017
462
Runtimes that are reading or processing this configuration file MUST generate an error when invalid or unsupported values are encountered.
Feb 7, 2017
Feb 7, 2017
463
Unless support for a valid value is explicitly required, runtimes MAY choose which subset of the valid values it will support.
464
Mar 9, 2016
Mar 9, 2016
465
## Configuration Schema Example
466
467
Here is a full example `config.json` for reference.
468
469
```json
470
{
Apr 11, 2016
Apr 11, 2016
471
"ociVersion": "0.5.0-dev",
Mar 9, 2016
Mar 9, 2016
472
"process": {
473
"terminal": true,
474
"user": {
475
"uid": 1,
476
"gid": 1,
477
"additionalGids": [
478
5,
479
6
480
]
481
},
482
"args": [
483
"sh"
484
],
485
"env": [
486
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
487
"TERM=xterm"
488
],
489
"cwd": "/",
Feb 22, 2017
Feb 22, 2017
490
"capabilities": {
491
"bounding": [
492
"CAP_AUDIT_WRITE",
493
"CAP_KILL",
494
"CAP_NET_BIND_SERVICE"
495
],
496
"permitted": [
497
"CAP_AUDIT_WRITE",
498
"CAP_KILL",
499
"CAP_NET_BIND_SERVICE"
500
],
501
"inheritable": [
502
"CAP_AUDIT_WRITE",
503
"CAP_KILL",
504
"CAP_NET_BIND_SERVICE"
505
],
506
"effective": [
507
"CAP_AUDIT_WRITE",
Mar 6, 2017
Mar 6, 2017
508
"CAP_KILL"
Feb 22, 2017
Feb 22, 2017
509
],
510
"ambient": [
511
"CAP_NET_BIND_SERVICE"
512
]
513
},
Mar 10, 2016
Mar 10, 2016
514
"rlimits": [
Apr 11, 2016
Apr 11, 2016
515
{
516
"type": "RLIMIT_CORE",
517
"hard": 1024,
518
"soft": 1024
519
},
Mar 10, 2016
Mar 10, 2016
520
{
521
"type": "RLIMIT_NOFILE",
522
"hard": 1024,
523
"soft": 1024
524
}
525
],
Apr 11, 2016
Apr 11, 2016
526
"apparmorProfile": "acme_secure_profile",
May 9, 2017
May 9, 2017
527
"oomScoreAdj": 100,
Apr 11, 2016
Apr 11, 2016
528
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
529
"noNewPrivileges": true
Mar 9, 2016
Mar 9, 2016
530
},
531
"root": {
532
"path": "rootfs",
533
"readonly": true
534
},
535
"hostname": "slartibartfast",
536
"mounts": [
537
{
538
"destination": "/proc",
539
"type": "proc",
540
"source": "proc"
541
},
542
{
543
"destination": "/dev",
544
"type": "tmpfs",
545
"source": "tmpfs",
546
"options": [
547
"nosuid",
548
"strictatime",
549
"mode=755",
550
"size=65536k"
551
]
552
},
553
{
554
"destination": "/dev/pts",
555
"type": "devpts",
556
"source": "devpts",
557
"options": [
558
"nosuid",
559
"noexec",
560
"newinstance",
561
"ptmxmode=0666",
562
"mode=0620",
563
"gid=5"
564
]
565
},
566
{
567
"destination": "/dev/shm",
568
"type": "tmpfs",
569
"source": "shm",
570
"options": [
571
"nosuid",
572
"noexec",
573
"nodev",
574
"mode=1777",
575
"size=65536k"
576
]
577
},
578
{
579
"destination": "/dev/mqueue",
580
"type": "mqueue",
581
"source": "mqueue",
582
"options": [
583
"nosuid",
584
"noexec",
585
"nodev"
586
]
587
},
588
{
589
"destination": "/sys",
590
"type": "sysfs",
591
"source": "sysfs",
592
"options": [
593
"nosuid",
594
"noexec",
595
"nodev"
596
]
597
},
598
{
599
"destination": "/sys/fs/cgroup",
600
"type": "cgroup",
601
"source": "cgroup",
602
"options": [
603
"nosuid",
604
"noexec",
605
"nodev",
606
"relatime",
607
"ro"
608
]
609
}
610
],
611
"hooks": {
612
"prestart": [
613
{
Apr 11, 2016
Apr 11, 2016
614
"path": "/usr/bin/fix-mounts",
Mar 9, 2016
Mar 9, 2016
615
"args": [
Apr 11, 2016
Apr 11, 2016
616
"fix-mounts",
617
"arg1",
618
"arg2"
Mar 9, 2016
Mar 9, 2016
619
],
Apr 11, 2016
Apr 11, 2016
620
"env": [
621
"key1=value1"
622
]
623
},
624
{
625
"path": "/usr/bin/setup-network"
626
}
627
],
628
"poststart": [
629
{
630
"path": "/usr/bin/notify-start",
631
"timeout": 5
632
}
633
],
634
"poststop": [
635
{
636
"path": "/usr/sbin/cleanup.sh",
637
"args": [
638
"cleanup.sh",
639
"-f"
640
]
Mar 9, 2016
Mar 9, 2016
641
}
642
]
643
},
644
"linux": {
Apr 11, 2016
Apr 11, 2016
645
"devices": [
646
{
647
"path": "/dev/fuse",
648
"type": "c",
649
"major": 10,
650
"minor": 229,
651
"fileMode": 438,
652
"uid": 0,
653
"gid": 0
654
},
655
{
656
"path": "/dev/sda",
657
"type": "b",
658
"major": 8,
659
"minor": 0,
660
"fileMode": 432,
661
"uid": 0,
662
"gid": 0
663
}
664
],
Apr 20, 2016
Apr 20, 2016
665
"uidMappings": [
666
{
667
"hostID": 1000,
668
"containerID": 0,
669
"size": 32000
670
}
671
],
672
"gidMappings": [
673
{
674
"hostID": 1000,
675
"containerID": 0,
676
"size": 32000
677
}
678
],
Apr 11, 2016
Apr 11, 2016
679
"sysctl": {
680
"net.ipv4.ip_forward": "1",
681
"net.core.somaxconn": "256"
682
},
683
"cgroupsPath": "/myRuntime/myContainer",
Mar 9, 2016
Mar 9, 2016
684
"resources": {
Apr 11, 2016
Apr 11, 2016
685
"network": {
686
"classID": 1048577,
687
"priorities": [
688
{
689
"name": "eth0",
690
"priority": 500
691
},
692
{
693
"name": "eth1",
694
"priority": 1000
695
}
696
]
697
},
698
"pids": {
699
"limit": 32771
700
},
701
"hugepageLimits": [
702
{
703
"pageSize": "2MB",
704
"limit": 9223372036854772000
705
}
706
],
707
"memory": {
708
"limit": 536870912,
709
"reservation": 536870912,
710
"swap": 536870912,
Jun 23, 2017
Jun 23, 2017
711
"kernel": -1,
712
"kernelTCP": -1,
Apr 11, 2016
Apr 11, 2016
713
"swappiness": 0
714
},
715
"cpu": {
716
"shares": 1024,
717
"quota": 1000000,
718
"period": 500000,
719
"realtimeRuntime": 950000,
720
"realtimePeriod": 1000000,
721
"cpus": "2-3",
722
"mems": "0-7"
723
},
724
"disableOOMKiller": false,
Mar 9, 2016
Mar 9, 2016
725
"devices": [
726
{
727
"allow": false,
728
"access": "rwm"
Apr 11, 2016
Apr 11, 2016
729
},
730
{
731
"allow": true,
732
"type": "c",
733
"major": 10,
734
"minor": 229,
735
"access": "rw"
736
},
737
{
738
"allow": true,
739
"type": "b",
740
"major": 8,
741
"minor": 0,
742
"access": "r"
743
}
744
],
745
"blockIO": {
Jun 1, 2017
Jun 1, 2017
746
"weight": 10,
747
"leafWeight": 10,
748
"weightDevice": [
Apr 11, 2016
Apr 11, 2016
749
{
750
"major": 8,
751
"minor": 0,
752
"weight": 500,
753
"leafWeight": 300
754
},
755
{
756
"major": 8,
757
"minor": 16,
758
"weight": 500
759
}
760
],
Jun 1, 2017
Jun 1, 2017
761
"throttleReadBpsDevice": [
Apr 11, 2016
Apr 11, 2016
762
{
763
"major": 8,
764
"minor": 0,
765
"rate": 600
766
}
767
],
Jun 1, 2017
Jun 1, 2017
768
"throttleWriteIOPSDevice": [
Apr 11, 2016
Apr 11, 2016
769
{
770
"major": 8,
771
"minor": 16,
772
"rate": 300
773
}
774
]
775
}
776
},
777
"rootfsPropagation": "slave",
778
"seccomp": {
779
"defaultAction": "SCMP_ACT_ALLOW",
780
"architectures": [
Feb 22, 2017
Feb 22, 2017
781
"SCMP_ARCH_X86",
782
"SCMP_ARCH_X32"
Apr 11, 2016
Apr 11, 2016
783
],
784
"syscalls": [
785
{
Feb 22, 2017
Feb 22, 2017
786
"names": [
787
"getcwd",
788
"chmod"
789
],
Mar 10, 2017
Mar 10, 2017
790
"action": "SCMP_ACT_ERRNO"
Mar 9, 2016
Mar 9, 2016
791
}
792
]
793
},
794
"namespaces": [
795
{
796
"type": "pid"
797
},
798
{
799
"type": "network"
800
},
801
{
802
"type": "ipc"
803
},
804
{
805
"type": "uts"
806
},
807
{
808
"type": "mount"
Jun 3, 2016
Jun 3, 2016
809
},
810
{
811
"type": "user"
812
},
813
{
814
"type": "cgroup"
Mar 9, 2016
Mar 9, 2016
815
}
Apr 11, 2016
Apr 11, 2016
816
],
817
"maskedPaths": [
818
"/proc/kcore",
819
"/proc/latency_stats",
820
"/proc/timer_stats",
821
"/proc/sched_debug"
822
],
823
"readonlyPaths": [
824
"/proc/asound",
825
"/proc/bus",
826
"/proc/fs",
827
"/proc/irq",
828
"/proc/sys",
829
"/proc/sysrq-trigger"
Apr 22, 2016
Apr 22, 2016
830
],
831
"mountLabel": "system_u:object_r:svirt_sandbox_file_t:s0:c715,c811"
Apr 11, 2016
Apr 11, 2016
832
},
833
"annotations": {
Sep 2, 2016
Sep 2, 2016
834
"com.example.key1": "value1",
835
"com.example.key2": "value2"
Mar 9, 2016
Mar 9, 2016
836
}
Mar 9, 2016
Mar 9, 2016
837
}
838
```
839
Mar 3, 2017
Mar 3, 2017
840
841
[apparmor]: https://wiki.ubuntu.com/AppArmor
May 9, 2017
May 9, 2017
842
[cgroup-v1-memory_2]: https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
Mar 3, 2017
Mar 3, 2017
843
[selinux]:http://selinuxproject.org/page/Main_Page
844
[no-new-privs]: https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt
May 9, 2017
May 9, 2017
845
[procfs_2]: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
Mar 3, 2017
Mar 3, 2017
846
[semver-v2.0.0]: http://semver.org/spec/v2.0.0.html
Jun 1, 2017
Jun 1, 2017
847
[ieee-1003.1-2008-xbd-c8.1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_01
848
[ieee-1003.1-2008-xsh-exec]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
May 24, 2017
May 24, 2017
849
[naming-a-volume]: https://aka.ms/nb3hqb
Mar 3, 2017
Mar 3, 2017
850
851
[capabilities.7]: http://man7.org/linux/man-pages/man7/capabilities.7.html
852
[mount.2]: http://man7.org/linux/man-pages/man2/mount.2.html
853
[mount.8]: http://man7.org/linux/man-pages/man8/mount.8.html
Sep 14, 2016
Sep 14, 2016
854
[mount.8-filesystem-independent]: http://man7.org/linux/man-pages/man8/mount.8.html#FILESYSTEM-INDEPENDENT_MOUNT%20OPTIONS
855
[mount.8-filesystem-specific]: http://man7.org/linux/man-pages/man8/mount.8.html#FILESYSTEM-SPECIFIC_MOUNT%20OPTIONS
Jul 5, 2017
Jul 5, 2017
856
[getrlimit.2]: http://man7.org/linux/man-pages/man2/getrlimit.2.html
857
[getrlimit.3]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html
Oct 19, 2016
Oct 19, 2016
858
[stdin.3]: http://man7.org/linux/man-pages/man3/stdin.3.html
Mar 3, 2017
Mar 3, 2017
859
[uts-namespace.7]: http://man7.org/linux/man-pages/man7/namespaces.7.html
May 26, 2017
May 26, 2017
860
[zonecfg.1m]: http://docs.oracle.com/cd/E86824_01/html/E54764/zonecfg-1m.html