Skip to content

Latest commit

 

History

History
862 lines (769 loc) · 31 KB

config.md

File metadata and controls

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