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. Background discussion in [1].
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. This will also make it easy to drop either
portion (mknod [2] or cgroups [3]) independently of the other if the
project decides to do so.
Using seperate sections for mknod and cgroups also allows us to avoid
the complicated validation rules needed for the combined format
mknod/cgroup [4].
Now that there is a section specific to supplying devices, I shifted
the default device listing over from config-linux [5]. 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. The cgroup link is new since 2016-01-13 [6].
[1]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/y_Fsa2_jJaM
Subject: Separate config entries for device mknod and cgroups?
Date: Mon, 5 Oct 2015 12:46:55 -0700
Message-ID: <[email protected]>
[2]: #98
[3]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/qWHoKs8Fsrk
Subject: removal of cgroups from the OCI Linux spec
Date: Wed, 28 Oct 2015 17:01:59 +0000
Message-ID: <CAD2oYtO1RMCcUp52w-xXemzDTs+J6t4hS5Mm4mX+uBnVONGDfA@mail.gmail.com>
[4]: #101
[5]: #171 (comment)
[6]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34a9304a96d6351c2d35dcdc9293258378fc0bd8
Signed-off-by: W. Trevor King <[email protected]>
@@ -115,93 +107,59 @@ There is a limit of 5 mappings which is the Linux kernel hard limit.
115
107
116
108
## Devices
117
109
118
-
`devices` is an array specifying the list of devices to be created in the container.
110
+
`devices` is an array specifying the list of devices that MUST be available in the container.
111
+
The runtime may supply them however it likes (with [mknod][mknod.2], by bind mounting from the runtime mount namespace, etc.).
119
112
120
113
The following parameters can be specified:
121
114
122
-
***`type`***(char, required)* - type of device: `c`, `b`, `u` or `p`. More info in `man mknod`.
123
-
124
-
***`path`***(string, optional)* - full path to device inside container
125
-
126
-
***`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.
127
-
128
-
***`permissions`***(string, optional)* - cgroup permissions for device. A composition of `r` (*read*), `w` (*write*), and `m` (*mknod*).
129
-
130
-
***`fileMode`***(uint32, optional)* - file mode for device file
131
-
132
-
***`uid`***(uint32, optional)* - uid of device owner
133
-
134
-
***`gid`***(uint32, optional)* - gid of device owner
135
-
136
-
**`fileMode`**, **`uid`** and **`gid`** are required if **`path`** is given and are otherwise not allowed.
115
+
***`type`***(char, required)* - type of device: `c`, `b`, `u` or `p`.
116
+
More info in [mknod(1)][mknod.1].
117
+
***`path`***(string, required)* - full path to device inside container.
118
+
***`major, minor`***(int64, required)* - [major, minor numbers][devices] for the device.
119
+
***`fileMode`***(uint32, required)* - file mode for the device.
120
+
You can also control access to devices [with cgroups](#device-whitelist).
121
+
***`uid`***(uint32, required)* - id of device owner.
122
+
***`gid`***(uint32, required)* - id of device group.
137
123
138
124
###### Example
139
125
140
126
```json
141
127
"devices": [
142
128
{
143
-
"path": "/dev/random",
129
+
"path": "/dev/fuse",
144
130
"type": "c",
145
-
"major": 1,
146
-
"minor": 8,
147
-
"permissions": "rwm",
131
+
"major": 10,
132
+
"minor": 229,
148
133
"fileMode": 0666,
149
134
"uid": 0,
150
135
"gid": 0
151
136
},
152
137
{
153
-
"path": "/dev/urandom",
154
-
"type": "c",
155
-
"major": 1,
156
-
"minor": 9,
157
-
"permissions": "rwm",
158
-
"fileMode": 0666,
159
-
"uid": 0,
160
-
"gid": 0
161
-
},
162
-
{
163
-
"path": "/dev/null",
164
-
"type": "c",
165
-
"major": 1,
166
-
"minor": 3,
167
-
"permissions": "rwm",
168
-
"fileMode": 0666,
169
-
"uid": 0,
170
-
"gid": 0
171
-
},
172
-
{
173
-
"path": "/dev/zero",
174
-
"type": "c",
175
-
"major": 1,
176
-
"minor": 5,
177
-
"permissions": "rwm",
178
-
"fileMode": 0666,
179
-
"uid": 0,
180
-
"gid": 0
181
-
},
182
-
{
183
-
"path": "/dev/tty",
184
-
"type": "c",
185
-
"major": 5,
138
+
"path": "/dev/sda",
139
+
"type": "b",
140
+
"major": 8,
186
141
"minor": 0,
187
-
"permissions": "rwm",
188
-
"fileMode": 0666,
189
-
"uid": 0,
190
-
"gid": 0
191
-
},
192
-
{
193
-
"path": "/dev/full",
194
-
"type": "c",
195
-
"major": 1,
196
-
"minor": 7,
197
-
"permissions": "rwm",
198
-
"fileMode": 0666,
142
+
"fileMode": 0660,
199
143
"uid": 0,
200
144
"gid": 0
201
145
}
202
146
]
203
147
```
204
148
149
+
###### Default Devices
150
+
151
+
In addition to any devices configured with this setting, the runtime MUST also supply:
152
+
153
+
*[`/dev/null`][null.4]
154
+
*[`/dev/zero`][zero.4]
155
+
*[`/dev/full`][full.4]
156
+
*[`/dev/random`][random.4]
157
+
*[`/dev/urandom`][random.4]
158
+
*[`/dev/tty`][tty.4]
159
+
*[`/dev/console`][console.4]
160
+
*[`/dev/ptmx`][pts.4].
161
+
A [bind-mount or symlink of the container's `/dev/pts/ptmx`][devpts].
162
+
205
163
## Control groups
206
164
207
165
Also known as cgroups, they are used to restrict resource usage for a container and handle device access.
@@ -228,6 +186,46 @@ You can configure a container's cgroups via the `resources` field of the Linux c
228
186
Do not specify `resources` unless limits have to be updated.
229
187
For example, to run a new process in an existing container without updating limits, `resources` need not be specified.
230
188
189
+
#### Device whitelist
190
+
191
+
`devices` is an array of entries to control the [device whitelist][cgroups-devices].
192
+
The runtime MUST apply entries in the listed order.
193
+
194
+
The following parameters can be specified:
195
+
196
+
***`allow`***(boolean, required)* - whether the entry is allowed or denied.
197
+
***`type`***(char, optional)* - type of device: `a` (all), `c` (char), or `b` (block).
198
+
`null` or unset values mean "all", mapping to `a`.
199
+
***`major, minor`***(int64, optional)* - [major, minor numbers][devices] for the device.
200
+
`null` or unset values mean "all", mapping to [`*` in the filesystem API][cgroups-devices].
201
+
***`access`***(string, required)* - cgroup permissions for device.
202
+
A composition of `r` (read), `w` (write), and `m` (mknod).
203
+
204
+
###### Example
205
+
206
+
```json
207
+
"devices": [
208
+
{
209
+
"allow": false,
210
+
"access": "rwm"
211
+
},
212
+
{
213
+
"allow": true,
214
+
"type": "c",
215
+
"major": 10,
216
+
"minor": 229,
217
+
"access": "rw"
218
+
},
219
+
{
220
+
"allow": true,
221
+
"type": "b",
222
+
"major": 8,
223
+
"minor": 0,
224
+
"access": "r"
225
+
}
226
+
]
227
+
```
228
+
231
229
#### Disable out-of-memory killer
232
230
233
231
`disableOOMKiller` contains a boolean (`true` or `false`) that enables or disables the Out of Memory killer for a cgroup.
@@ -587,3 +585,17 @@ Setting `noNewPrivileges` to true prevents the processes in the container from g
0 commit comments