Skip to content

Latest commit

 

History

History
839 lines (755 loc) · 29.7 KB

File metadata and controls

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