Add info on --device flag permissions ':rwm'
| ... | ... |
@@ -61,7 +61,7 @@ docker-create - Create a new container |
| 61 | 61 |
CPUs in which to allow execution (0-3, 0,1) |
| 62 | 62 |
|
| 63 | 63 |
**--device**=[] |
| 64 |
- Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc) |
|
| 64 |
+ Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm) |
|
| 65 | 65 |
|
| 66 | 66 |
**--dns-search**=[] |
| 67 | 67 |
Set custom DNS search domains |
| ... | ... |
@@ -98,8 +98,9 @@ the detached mode, then you cannot use the **-rm** option. |
| 98 | 98 |
|
| 99 | 99 |
When attached in the tty mode, you can detach from a running container without |
| 100 | 100 |
stopping the process by pressing the keys CTRL-P CTRL-Q. |
| 101 |
+ |
|
| 101 | 102 |
**--device**=[] |
| 102 |
- Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc) |
|
| 103 |
+ Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm) |
|
| 103 | 104 |
|
| 104 | 105 |
**--dns-search**=[] |
| 105 | 106 |
Set custom DNS search domains |
| ... | ... |
@@ -487,7 +487,7 @@ Creates a new container. |
| 487 | 487 |
--cap-drop=[] Drop Linux capabilities |
| 488 | 488 |
--cidfile="" Write the container ID to the file |
| 489 | 489 |
--cpuset="" CPUs in which to allow execution (0-3, 0,1) |
| 490 |
- --device=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc) |
|
| 490 |
+ --device=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm) |
|
| 491 | 491 |
--dns=[] Set custom DNS servers |
| 492 | 492 |
--dns-search=[] Set custom DNS search domains |
| 493 | 493 |
-e, --env=[] Set environment variables |
| ... | ... |
@@ -527,6 +527,8 @@ container at any point. |
| 527 | 527 |
This is useful when you want to set up a container configuration ahead |
| 528 | 528 |
of time so that it is ready to start when you need it. |
| 529 | 529 |
|
| 530 |
+Please see the [run command](#run) section for more details. |
|
| 531 |
+ |
|
| 530 | 532 |
#### Example |
| 531 | 533 |
|
| 532 | 534 |
$ sudo docker create -t -i fedora bash |
| ... | ... |
@@ -1185,7 +1187,7 @@ removed before the image is removed. |
| 1185 | 1185 |
--cidfile="" Write the container ID to the file |
| 1186 | 1186 |
--cpuset="" CPUs in which to allow execution (0-3, 0,1) |
| 1187 | 1187 |
-d, --detach=false Detached mode: run the container in the background and print the new container ID |
| 1188 |
- --device=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc) |
|
| 1188 |
+ --device=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm) |
|
| 1189 | 1189 |
--dns=[] Set custom DNS servers |
| 1190 | 1190 |
--dns-search=[] Set custom DNS search domains |
| 1191 | 1191 |
-e, --env=[] Set environment variables |
| ... | ... |
@@ -1394,8 +1396,31 @@ option enables that. For example, a specific block storage device or loop |
| 1394 | 1394 |
device or audio device can be added to an otherwise unprivileged container |
| 1395 | 1395 |
(without the `--privileged` flag) and have the application directly access it. |
| 1396 | 1396 |
|
| 1397 |
+By default, the container will be able to `read`, `write` and `mknod` these devices. |
|
| 1398 |
+This can be overridden using a third `:rwm` set of options to each `--device` |
|
| 1399 |
+flag: |
|
| 1400 |
+ |
|
| 1401 |
+ |
|
| 1402 |
+``` |
|
| 1403 |
+ $ sudo docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc |
|
| 1404 |
+ |
|
| 1405 |
+ Command (m for help): q |
|
| 1406 |
+ $ sudo docker run --device=/dev/sda:/dev/xvdc:r --rm -it ubuntu fdisk /dev/xvdc |
|
| 1407 |
+ You will not be able to write the partition table. |
|
| 1408 |
+ |
|
| 1409 |
+ Command (m for help): q |
|
| 1410 |
+ |
|
| 1411 |
+ $ sudo docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc |
|
| 1412 |
+ |
|
| 1413 |
+ Command (m for help): q |
|
| 1414 |
+ |
|
| 1415 |
+ $ sudo docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk /dev/xvdc |
|
| 1416 |
+ fdisk: unable to open /dev/xvdc: Operation not permitted |
|
| 1417 |
+``` |
|
| 1418 |
+ |
|
| 1397 | 1419 |
**Note:** |
| 1398 |
-> `--device` cannot be safely used with ephemeral devices. Block devices that may be removed should not be added to untrusted containers with `--device`. |
|
| 1420 |
+> `--device` cannot be safely used with ephemeral devices. Block devices that |
|
| 1421 |
+> may be removed should not be added to untrusted containers with `--device`. |
|
| 1399 | 1422 |
|
| 1400 | 1423 |
**A complete example:** |
| 1401 | 1424 |
|
| ... | ... |
@@ -308,6 +308,26 @@ will be accessible within the container. |
| 308 | 308 |
|
| 309 | 309 |
$ sudo docker run --device=/dev/snd:/dev/snd ... |
| 310 | 310 |
|
| 311 |
+By default, the container will be able to `read`, `write`, and `mknod` these devices. |
|
| 312 |
+This can be overridden using a third `:rwm` set of options to each `--device` flag: |
|
| 313 |
+ |
|
| 314 |
+ |
|
| 315 |
+``` |
|
| 316 |
+ $ sudo docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc |
|
| 317 |
+ |
|
| 318 |
+ Command (m for help): q |
|
| 319 |
+ $ sudo docker run --device=/dev/sda:/dev/xvdc:r --rm -it ubuntu fdisk /dev/xvdc |
|
| 320 |
+ You will not be able to write the partition table. |
|
| 321 |
+ |
|
| 322 |
+ Command (m for help): q |
|
| 323 |
+ |
|
| 324 |
+ $ sudo docker run --device=/dev/sda:/dev/xvdc:w --rm -it ubuntu fdisk /dev/xvdc |
|
| 325 |
+ crash.... |
|
| 326 |
+ |
|
| 327 |
+ $ sudo docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk /dev/xvdc |
|
| 328 |
+ fdisk: unable to open /dev/xvdc: Operation not permitted |
|
| 329 |
+``` |
|
| 330 |
+ |
|
| 311 | 331 |
In addition to `--privileged`, the operator can have fine grain control over the |
| 312 | 332 |
capabilities using `--cap-add` and `--cap-drop`. By default, Docker has a default |
| 313 | 333 |
list of capabilities that are kept. Both flags support the value `all`, so if the |
| ... | ... |
@@ -65,7 +65,7 @@ func Parse(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Config, |
| 65 | 65 |
cmd.Var(&flAttach, []string{"a", "-attach"}, "Attach to STDIN, STDOUT or STDERR.")
|
| 66 | 66 |
cmd.Var(&flVolumes, []string{"v", "-volume"}, "Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container)")
|
| 67 | 67 |
cmd.Var(&flLinks, []string{"#link", "-link"}, "Add link to another container in the form of name:alias")
|
| 68 |
- cmd.Var(&flDevices, []string{"-device"}, "Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc)")
|
|
| 68 |
+ cmd.Var(&flDevices, []string{"-device"}, "Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)")
|
|
| 69 | 69 |
|
| 70 | 70 |
cmd.Var(&flEnv, []string{"e", "-env"}, "Set environment variables")
|
| 71 | 71 |
cmd.Var(&flEnvFile, []string{"-env-file"}, "Read in a line delimited file of environment variables")
|