Skip to content

Latest commit

 

History

History
151 lines (115 loc) · 6.11 KB

config.md

File metadata and controls

151 lines (115 loc) · 6.11 KB
 
Jun 25, 2015
Jun 25, 2015
1
2
# Configuration file
Jun 30, 2015
Jun 30, 2015
3
4
The container’s top-level directory MUST contain a configuration file called `config.json`.
For now the schema is defined in [spec.go](https://github.com/opencontainers/runc/blob/master/spec.go) and [spec_linux.go](https://github.com/opencontainers/runc/blob/master/spec_linux.go), this will be moved to a JSON schema overtime.
Jun 25, 2015
Jun 25, 2015
5
Jun 30, 2015
Jun 30, 2015
6
7
The configuration file contains metadata necessary to implement standard operations against the container.
This includes the process to run, environment variables to inject, sandboxing features to use, etc.
Jun 25, 2015
Jun 25, 2015
8
9
10
11
12
Below is a detailed description of each field defined in the configuration format.
## Manifest version
Jun 30, 2015
Jun 30, 2015
13
* **version** (string, required) must be in SemVer v2.0.0 format and specifies the version of the OCF specification which the container bundle complies. The Open Container spec follows semantic versioning and retain forward and backwards compatibility within major versions. For example, if an implementation is compliant against version 1.0.1 of the spec, it is compatible with the complete 1.x series.
Jun 25, 2015
Jun 25, 2015
14
Jun 29, 2015
Jun 29, 2015
15
*Example*
Jun 30, 2015
Jun 30, 2015
16
Jun 29, 2015
Jun 29, 2015
17
```json
Jul 1, 2015
Jul 1, 2015
18
"version": "0.1.0"
Jun 25, 2015
Jun 25, 2015
19
20
```
Jun 30, 2015
Jun 30, 2015
21
## Root Configuration
Jun 25, 2015
Jun 25, 2015
22
Jun 30, 2015
Jun 30, 2015
23
24
* **path** (string, required) Each container has exactly one *root filesystem*. The path string element specifies the path to the root file system for the container, relative to the path where the manifest is. A directory MUST exist at the relative path declared by the field.
* **readonly** (bool, optional) If true then the root file system MUST be read-only inside the container. Defaults to false.
Jun 25, 2015
Jun 25, 2015
25
Jun 29, 2015
Jun 29, 2015
26
*Example*
Jun 30, 2015
Jun 30, 2015
27
Jun 29, 2015
Jun 29, 2015
28
```json
Jun 30, 2015
Jun 30, 2015
29
30
31
32
"root": {
"path": "rootfs",
"readonly": true
}
Jun 25, 2015
Jun 25, 2015
33
34
```
Jun 30, 2015
Jun 30, 2015
35
## Mount Configuration
Jun 25, 2015
Jun 25, 2015
36
Jun 30, 2015
Jun 30, 2015
37
Additional file systems can be declared as "mounts", declared by the array element mounts. The parameters are similar to the ones in Linux mount system call. [http://linux.die.net/man/2/mount](http://linux.die.net/man/2/mount)
Jun 25, 2015
Jun 25, 2015
38
Jun 30, 2015
Jun 30, 2015
39
40
* **type** (string, required) Linux, *filesystemtype* argument supported by the kernel are listed in */proc/filesystems* (e.g., "minix", "ext2", "ext3", "jfs", "xfs", "reiserfs", "msdos", "proc", "nfs", "iso9660"). Windows: ntfs
* **source** (string, required) a device name, but can also be a directory name or a dummy. Windows, the volume name that is the target of the mount point. \\?\Volume\{GUID}\ (on Windows source is called target)
Jun 30, 2015
Jun 30, 2015
41
* **destination** (string, required) where the source file system is mounted relative to the container rootfs.
Jun 30, 2015
Jun 30, 2015
42
* **options** (string, optional) in the fstab format [https://wiki.archlinux.org/index.php/Fstab](https://wiki.archlinux.org/index.php/Fstab).
Jun 25, 2015
Jun 25, 2015
43
44
45
*Example (Linux)*
Jun 29, 2015
Jun 29, 2015
46
```json
Jun 30, 2015
Jun 30, 2015
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"mounts": [
{
"type": "proc",
"source": "proc",
"destination": "/proc",
"options": ""
},
{
"type": "tmpfs",
"source": "tmpfs",
"destination": "/dev",
"options": "nosuid,strictatime,mode=755,size=65536k"
},
{
"type": "devpts",
"source": "devpts",
"destination": "/dev/pts",
"options": "nosuid,noexec,newinstance,ptmxmode=0666,mode=0620,gid=5"
},
{
Jun 30, 2015
Jun 30, 2015
67
68
69
70
71
"type": "bind",
"source": "/volumes/testing",
"destination": "/data",
"options": "rbind,rw"
}
Jun 30, 2015
Jun 30, 2015
72
]
Jun 25, 2015
Jun 25, 2015
73
74
75
```
*Example (Windows)*
Jun 30, 2015
Jun 30, 2015
76
Jun 29, 2015
Jun 29, 2015
77
```json
Jun 30, 2015
Jun 30, 2015
78
79
80
81
82
83
84
85
"mounts": [
{
"type": "ntfs",
"source": "\\?\Volume\{2eca078d-5cbc-43d3-aff8-7e8511f60d0e}\",
"destination": "C:\Users\crosbymichael\My Fancy Mount Point\",
"options": ""
}
]
Jun 25, 2015
Jun 25, 2015
86
87
```
Jun 30, 2015
Jun 30, 2015
88
See links for details about [mountvol](http://ss64.com/nt/mountvol.html) and [SetVolumeMountPoint](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365561(v=vs.85).aspx) in Windows.
Jun 25, 2015
Jun 25, 2015
89
Jun 30, 2015
Jun 30, 2015
90
## Processes configuration
Jun 25, 2015
Jun 25, 2015
91
Jun 30, 2015
Jun 30, 2015
92
93
94
95
* **terminal** (bool, optional) specifies whether you want a terminal attached to that process. Defaults to false.
* **cwd** (string, optional) is the working directory that will be set for the executable.
* **env** (array of strings, optional) contains a list of variables that will be set in the processes environment prior to execution. Elements in the array are specified as Strings in the form "KEY=value". The left hand side must consist solely of letters, digits, and underscores '_' as outlined in [IEEE Std 1003.1-2001](http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html).
* **args** (string, required) executable to launch and any flags as an array. The executable is the first element and must be available at the given path inside of the rootfs. If the executable path is not an absoulte path then the search $PATH is interpreted to find the executable.
Jun 25, 2015
Jun 25, 2015
96
Jun 30, 2015
Jun 30, 2015
97
98
99
100
101
102
103
104
The user for the process is a platform specific structure that allows specific control
over which user the process runs as. For linux based systems the user structure has the
following fields:
* **uid** (int, required) specifies the user id.
* **gid** (int, required) specifies the group id.
* **additionalGids** (array of ints, optional) specifies additional group ids to be added to the process.
Jun 29, 2015
Jun 29, 2015
105
*Example*
Jun 30, 2015
Jun 30, 2015
106
Jun 29, 2015
Jun 29, 2015
107
```json
Jun 30, 2015
Jun 30, 2015
108
109
"process": {
"terminal": true,
Jun 30, 2015
Jun 30, 2015
110
111
112
113
114
"user": {
"uid": 1,
"gid": 1,
"additionalGids": []
},
Jun 30, 2015
Jun 30, 2015
115
116
117
118
119
120
121
122
123
"env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm"
],
"cwd": "",
"args": [
"sh"
]
}
Jun 25, 2015
Jun 25, 2015
124
125
126
```
Jun 30, 2015
Jun 30, 2015
127
## Hostname
Jun 25, 2015
Jun 25, 2015
128
Jun 30, 2015
Jun 30, 2015
129
* **hostname** (string, optional) as it is accessible to processes running inside.
Jun 25, 2015
Jun 25, 2015
130
131
*Example*
Jun 30, 2015
Jun 30, 2015
132
Jun 29, 2015
Jun 29, 2015
133
```json
Jun 30, 2015
Jun 30, 2015
134
"hostname": "mrsdalloway"
Jun 25, 2015
Jun 25, 2015
135
136
137
138
```
## Machine-specific configuration
Jun 30, 2015
Jun 30, 2015
139
140
141
* **os** (string, required) specifies the operating system family this image must run on. Values for arch must be in the list specified by the Go Language document for [$GOOS](https://golang.org/doc/install/source#environment).
* **arch** (string, required) specifies the instruction set for which the binaries in the image have been compiled. Values for arch must be in the list specified by the Go Language document for [$GOARCH](https://golang.org/doc/install/source#environment).
Jun 29, 2015
Jun 29, 2015
142
```json
Jun 30, 2015
Jun 30, 2015
143
144
145
146
"platform": {
"os": "linux",
"arch": "amd64"
}
Jun 25, 2015
Jun 25, 2015
147
148
```
Jun 30, 2015
Jun 30, 2015
149
Interpretation of the platform section of the JSON file is used to find which platform specific section may be availble in the document. For example if `os` is set to `linux` then the `linux` JSON object SHOULD be found in the `config.json`.