cli: add `--mount` to `docker run`

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2017-03-31 06:41:45 +00:00 committed by Tibor Vass
parent 95c05a53c6
commit 6103806802
6 changed files with 72 additions and 0 deletions

View File

@ -1518,6 +1518,7 @@ _docker_container_run_and_create() {
--memory-swap --memory-swap
--memory-swappiness --memory-swappiness
--memory-reservation --memory-reservation
--mount
--name --name
--network --network
--network-alias --network-alias

View File

@ -138,6 +138,7 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l link -d 'Add
complete -c docker -A -f -n '__fish_seen_subcommand_from create' -s m -l memory -d 'Memory limit (format: <number>[<unit>], where unit = b, k, m or g)' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -s m -l memory -d 'Memory limit (format: <number>[<unit>], where unit = b, k, m or g)'
complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l mac-address -d 'Container MAC address (e.g., 92:d0:c6:0a:29:33)' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l mac-address -d 'Container MAC address (e.g., 92:d0:c6:0a:29:33)'
complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l memory-swap -d "Total memory usage (memory + swap), set '-1' to disable swap (format: <number>[<unit>], where unit = b, k, m or g)" complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l memory-swap -d "Total memory usage (memory + swap), set '-1' to disable swap (format: <number>[<unit>], where unit = b, k, m or g)"
complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l mount -d 'Attach a filesystem mount to the container'
complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l name -d 'Assign a name to the container' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l name -d 'Assign a name to the container'
complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l net -d 'Set the Network mode for the container' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l net -d 'Set the Network mode for the container'
complete -c docker -A -f -n '__fish_seen_subcommand_from create' -s P -l publish-all -d 'Publish all exposed ports to random ports on the host interfaces' complete -c docker -A -f -n '__fish_seen_subcommand_from create' -s P -l publish-all -d 'Publish all exposed ports to random ports on the host interfaces'
@ -330,6 +331,7 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l link -d 'Add li
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s m -l memory -d 'Memory limit (format: <number>[<unit>], where unit = b, k, m or g)' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s m -l memory -d 'Memory limit (format: <number>[<unit>], where unit = b, k, m or g)'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l mac-address -d 'Container MAC address (e.g., 92:d0:c6:0a:29:33)' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l mac-address -d 'Container MAC address (e.g., 92:d0:c6:0a:29:33)'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l memory-swap -d "Total memory usage (memory + swap), set '-1' to disable swap (format: <number>[<unit>], where unit = b, k, m or g)" complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l memory-swap -d "Total memory usage (memory + swap), set '-1' to disable swap (format: <number>[<unit>], where unit = b, k, m or g)"
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l mount -d 'Attach a filesystem mount to the container'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l name -d 'Assign a name to the container' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l name -d 'Assign a name to the container'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l net -d 'Set the Network mode for the container' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l net -d 'Set the Network mode for the container'
complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s P -l publish-all -d 'Publish all exposed ports to random ports on the host interfaces' complete -c docker -A -f -n '__fish_seen_subcommand_from run' -s P -l publish-all -d 'Publish all exposed ports to random ports on the host interfaces'

View File

@ -629,6 +629,7 @@ __docker_container_subcommand() {
"($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers" "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers"
"($help)*--log-opt=[Log driver specific options]:log driver options:__docker_complete_log_options" "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_complete_log_options"
"($help)--mac-address=[Container MAC address]:MAC address: " "($help)--mac-address=[Container MAC address]:MAC address: "
"($help)*--mount=[Attach a filesystem mount to the container]:mount: "
"($help)--name=[Container name]:name: " "($help)--name=[Container name]:name: "
"($help)--network=[Connect a container to a network]:network mode:(bridge none container host)" "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)"
"($help)*--network-alias=[Add network-scoped alias for the container]:alias: " "($help)*--network-alias=[Add network-scoped alias for the container]:alias: "

View File

@ -85,6 +85,7 @@ Options:
--memory-reservation string Memory soft limit --memory-reservation string Memory soft limit
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)
--mount value Attach a filesytem mount to the container (default [])
--name string Assign a name to the container --name string Assign a name to the container
--network-alias value Add network-scoped alias for the container (default []) --network-alias value Add network-scoped alias for the container (default [])
--network string Connect a container to a network (default "default") --network string Connect a container to a network (default "default")

View File

@ -95,6 +95,7 @@ Options:
--memory-reservation string Memory soft limit --memory-reservation string Memory soft limit
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)
--mount value Attach a filesystem mount to the container (default [])
--name string Assign a name to the container --name string Assign a name to the container
--network-alias value Add network-scoped alias for the container (default []) --network-alias value Add network-scoped alias for the container (default [])
--network string Connect a container to a network --network string Connect a container to a network
@ -316,6 +317,29 @@ docker run -v c:\foo:c:\existing-directory-with-contents ...
For in-depth information about volumes, refer to [manage data in containers](https://docs.docker.com/engine/tutorials/dockervolumes/) For in-depth information about volumes, refer to [manage data in containers](https://docs.docker.com/engine/tutorials/dockervolumes/)
### Add bind-mounts or volumes using the --mount flag
The `--mount` flag allows you to mount volumes, host-directories and `tmpfs`
mounts in a container.
The `--mount` flag supports most options that are supported by the `-v` or the
`--volume` flag, but uses a different syntax. For in-depth information on the
`--mount` flag, and a comparison between `--volume` and `--mount`, refer to
the [service create command reference](service_create.md#add-bind-mounts-or-volumes).
Even though there is no plan to deprecate `--volume`, usage of `--mount` is recommended.
Examples:
```bash
$ docker run --read-only --mount type=volume,target=/icanwrite busybox touch /icanwrite/here
```
```bash
$ docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh
```
### Publish or expose port (-p, --expose) ### Publish or expose port (-p, --expose)
```bash ```bash

View File

@ -61,6 +61,7 @@ docker-run - Run a command in a new container
[**--memory-reservation**[=*MEMORY-RESERVATION*]] [**--memory-reservation**[=*MEMORY-RESERVATION*]]
[**--memory-swap**[=*LIMIT*]] [**--memory-swap**[=*LIMIT*]]
[**--memory-swappiness**[=*MEMORY-SWAPPINESS*]] [**--memory-swappiness**[=*MEMORY-SWAPPINESS*]]
[**--mount**[=*[MOUNT]*]]
[**--name**[=*NAME*]] [**--name**[=*NAME*]]
[**--network-alias**[=*[]*]] [**--network-alias**[=*[]*]]
[**--network**[=*"bridge"*]] [**--network**[=*"bridge"*]]
@ -425,6 +426,42 @@ unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap.
The IPv6 link-local address will be based on the device's MAC address The IPv6 link-local address will be based on the device's MAC address
according to RFC4862. according to RFC4862.
**--mount**=[*[type=TYPE[,TYPE-SPECIFIC-OPTIONS]]*]
Attach a filesystem mount to the container
Current supported mount `TYPES` are `bind`, `volume`, and `tmpfs`.
e.g.
`type=bind,source=/path/on/host,destination=/path/in/container`
`type=volume,source=my-volume,destination=/path/in/container,volume-label="color=red",volume-label="shape=round"`
`type=tmpfs,tmpfs-size=512M,destination=/path/in/container`
Common Options:
* `src`, `source`: mount source spec for `bind` and `volume`. Mandatory for `bind`.
* `dst`, `destination`, `target`: mount destination spec.
* `ro`, `read-only`: `true` or `false` (default).
Options specific to `bind`:
* `bind-propagation`: `shared`, `slave`, `private`, `rshared`, `rslave`, or `rprivate`(default). See also `mount(2)`.
* `consistency`: `consistent`(default), `cached`, or `delegated`. Currently, only effective for Docker for Mac.
Options specific to `volume`:
* `volume-driver`: Name of the volume-driver plugin.
* `volume-label`: Custom metadata.
* `volume-nocopy`: `true`(default) or `false`. If set to `false`, the Engine copies existing files and directories under the mount-path into the volume, allowing the host to access them.
* `volume-opt`: specific to a given volume driver.
Options specific to `tmpfs`:
* `tmpfs-size`: Size of the tmpfs mount in bytes. Unlimited by default in Linux.
* `tmpfs-mode`: File mode of the tmpfs in octal. (e.g. `700` or `0700`.) Defaults to `1777` in Linux.
**--name**="" **--name**=""
Assign a name to the container Assign a name to the container
@ -604,6 +641,9 @@ options are the same as the Linux default `mount` flags. If you do not specify
any options, the systems uses the following options: any options, the systems uses the following options:
`rw,noexec,nosuid,nodev,size=65536k`. `rw,noexec,nosuid,nodev,size=65536k`.
See also `--mount`, which is the successor of `--tmpfs` and `--volume`.
Even though there is no plan to deprecate `--tmpfs`, usage of `--mount` is recommended.
**-u**, **--user**="" **-u**, **--user**=""
Sets the username or UID used and optionally the groupname or GID for the specified command. Sets the username or UID used and optionally the groupname or GID for the specified command.
@ -704,6 +744,9 @@ change propagation properties of source mount. Say `/` is source mount for
To disable automatic copying of data from the container path to the volume, use To disable automatic copying of data from the container path to the volume, use
the `nocopy` flag. The `nocopy` flag can be set on bind mounts and named volumes. the `nocopy` flag. The `nocopy` flag can be set on bind mounts and named volumes.
See also `--mount`, which is the successor of `--tmpfs` and `--volume`.
Even though there is no plan to deprecate `--volume`, usage of `--mount` is recommended.
**--volume-driver**="" **--volume-driver**=""
Container's volume driver. This driver creates volumes specified either from Container's volume driver. This driver creates volumes specified either from
a Dockerfile's `VOLUME` instruction or from the `docker run -v` flag. a Dockerfile's `VOLUME` instruction or from the `docker run -v` flag.