You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With mknod entries in linux.devices and cgroups entries in
linux.resources.devices.
For specifying device cgroups independent of device creation. This
makes it easy to distinguish between configs that call for cgroup
adjustments (which have linux.resources entries) from those that
don't. Without this split, folks interested in making that
distinction would have to parse the device section to determine if it
included cgroup changes.
Using seperate sections for mknod and cgroups also allows us to avoid
the complicated validation rules needed for the combined format
mknod/cgroup [1].
Now that there is a section specific to supplying devices, I shifted
the default device listing over from config-linux. The /dev/ptmx
entry is a bit awkward, since it's not a device, but it seemed to fit
better over here. But I would also be fine leaving it with the other
mounts in config-linux.
The reference links are sorted into two blocks, with kernel-doc links
sorted alphabetically followed by man pages sorted alphabetically by
section.
[1]: opencontainers#101
Signed-off-by: W. Trevor King <wking@tremily.us>
Copy file name to clipboardExpand all lines: runtime-config-linux.md
+85-65Lines changed: 85 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,93 +77,59 @@ There is a limit of 5 mappings which is the Linux kernel hard limit.
77
77
78
78
## Devices
79
79
80
-
`devices` is an array specifying the list of devices to be created in the container.
80
+
`devices` is an array specifying the list of devices that the MUST be available in the container.
81
+
The runtime may supply them however it likes (with [mknod][mknod.2], by bind mounting from the runtime mount namespace, etc.).
81
82
82
83
The following parameters can be specified:
83
84
84
-
***`type`***(char, required)* - type of device: `c`, `b`, `u` or `p`. More info in `man mknod`.
85
-
86
-
***`path`***(string, optional)* - full path to device inside container
87
-
88
-
***`major, minor`***(int64, required)* - major, minor numbers for device. More info in `man mknod`. There is a special value: `-1`, which means `*` for `device` cgroup setup.
89
-
90
-
***`permissions`***(string, optional)* - cgroup permissions for device. A composition of `r` (*read*), `w` (*write*), and `m` (*mknod*).
91
-
92
-
***`fileMode`***(uint32, optional)* - file mode for device file
93
-
94
-
***`uid`***(uint32, optional)* - uid of device owner
95
-
96
-
***`gid`***(uint32, optional)* - gid of device owner
97
-
98
-
**`fileMode`**, **`uid`** and **`gid`** are required if **`path`** is given and are otherwise not allowed.
85
+
***`type`***(char, required)* - type of device: `c`, `b`, `u` or `p`.
86
+
More info in [mknod(1)][mknod.1].
87
+
***`path`***(string, required)* - full path to device inside container.
88
+
***`major, minor`***(int64, required)* - [major, minor numbers][devices] for the device.
89
+
***`fileMode`***(uint32, required)* - file mode for the device.
90
+
You can also control access to devices [with cgroups](#device-whitelist).
91
+
***`uid`***(uint32, required)* - id of device owner.
92
+
***`gid`***(uint32, required)* - id of device group.
99
93
100
94
###### Example
101
95
102
96
```json
103
97
"devices": [
104
98
{
105
-
"path": "/dev/random",
99
+
"path": "/dev/fuse",
106
100
"type": "c",
107
-
"major": 1,
108
-
"minor": 8,
109
-
"permissions": "rwm",
101
+
"major": 10,
102
+
"minor": 229,
110
103
"fileMode": 0666,
111
104
"uid": 0,
112
105
"gid": 0
113
106
},
114
107
{
115
-
"path": "/dev/urandom",
116
-
"type": "c",
117
-
"major": 1,
118
-
"minor": 9,
119
-
"permissions": "rwm",
120
-
"fileMode": 0666,
121
-
"uid": 0,
122
-
"gid": 0
123
-
},
124
-
{
125
-
"path": "/dev/null",
126
-
"type": "c",
127
-
"major": 1,
128
-
"minor": 3,
129
-
"permissions": "rwm",
130
-
"fileMode": 0666,
131
-
"uid": 0,
132
-
"gid": 0
133
-
},
134
-
{
135
-
"path": "/dev/zero",
136
-
"type": "c",
137
-
"major": 1,
138
-
"minor": 5,
139
-
"permissions": "rwm",
140
-
"fileMode": 0666,
141
-
"uid": 0,
142
-
"gid": 0
143
-
},
144
-
{
145
-
"path": "/dev/tty",
146
-
"type": "c",
147
-
"major": 5,
108
+
"path": "/dev/sda",
109
+
"type": "b",
110
+
"major": 8,
148
111
"minor": 0,
149
-
"permissions": "rwm",
150
-
"fileMode": 0666,
151
-
"uid": 0,
152
-
"gid": 0
153
-
},
154
-
{
155
-
"path": "/dev/full",
156
-
"type": "c",
157
-
"major": 1,
158
-
"minor": 7,
159
-
"permissions": "rwm",
160
-
"fileMode": 0666,
112
+
"fileMode": 0660,
161
113
"uid": 0,
162
114
"gid": 0
163
115
}
164
116
]
165
117
```
166
118
119
+
###### Default Devices
120
+
121
+
In addition to any devices configured with this setting, the runtime MUST also supply:
122
+
123
+
*[`/dev/null`][null.4]
124
+
*[`/dev/zero`][zero.4]
125
+
*[`/dev/full`][full.4]
126
+
*[`/dev/random`][random.4]
127
+
*[`/dev/urandom`][random.4]
128
+
*[`/dev/tty`][tty.4]
129
+
*[`/dev/console`][console.4]
130
+
*[`/dev/ptmx`][pts.4].
131
+
A [bind-mount or symlink of the container's `/dev/pts/ptmx`][devpts].
132
+
167
133
## Control groups
168
134
169
135
Also known as cgroups, they are used to restrict resource usage for a container and handle device access.
@@ -190,6 +156,46 @@ You can configure a container's cgroups via the `resources` field of the Linux c
190
156
Do not specify `resources` unless limits have to be updated.
191
157
For example, to run a new process in an existing container without updating limits, `resources` need not be specified.
192
158
159
+
#### Device whitelist
160
+
161
+
`devices` is an array of entries to control the [device whitelist][cgroups-devices].
162
+
The runtime MUST apply entries in the listed order.
163
+
164
+
The following parameters can be specified:
165
+
166
+
***`allow`***(boolean, required)* - whether the entry is allowed or denied.
167
+
***`type`***(char, optional)* - type of device: `a` (all), `c` (char), or `b` (block).
168
+
`null` or unset values mean "all", mapping to `a`.
169
+
***`major, minor`***(int64, optional)* - [major, minor numbers][devices] for the device.
170
+
`null` or unset values mean "all", mapping to [`*` in the filesystem API][cgroups-devices].
171
+
***`access`***(string, required)* - cgroup permissions for device.
172
+
A composition of `r` (read), `w` (write), and `m` (mknod).
173
+
174
+
###### Example
175
+
176
+
```json
177
+
"devices": [
178
+
{
179
+
"allow": false,
180
+
"access": "rwm"
181
+
},
182
+
{
183
+
"allow": true,
184
+
"type": "c",
185
+
"major": 10,
186
+
"minor": 229,
187
+
"access": "rw"
188
+
},
189
+
{
190
+
"allow": true,
191
+
"type": "b",
192
+
"major": 8,
193
+
"minor": 0,
194
+
"access": "r"
195
+
}
196
+
]
197
+
```
198
+
193
199
#### Disable out-of-memory killer
194
200
195
201
`disableOOMKiller` contains a boolean (`true` or `false`) that enables or disables the Out of Memory killer for a cgroup.
@@ -540,3 +546,17 @@ Its value is either slave, private, or shared.
0 commit comments