From 0e7bbb55c8024cd6cdec9ef5eb9a8483536f0058 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 25 Oct 2016 03:26:54 +0000 Subject: [PATCH] cli: add `--mount` to `docker run` Signed-off-by: Akihiro Suda --- contrib/completion/bash/docker | 1 + contrib/completion/fish/docker.fish | 2 ++ contrib/completion/zsh/_docker | 3 ++- docs/reference/commandline/create.md | 1 + docs/reference/commandline/run.md | 16 ++++++++++++++++ docs/reference/commandline/service_create.md | 2 +- man/docker-create.1.md | 1 + man/docker-run.1.md | 1 + 8 files changed, 25 insertions(+), 2 deletions(-) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index ebd108d7c1..973684a82f 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1268,6 +1268,7 @@ _docker_container_run() { --memory-swap --memory-swappiness --memory-reservation + --mount --name --network --network-alias diff --git a/contrib/completion/fish/docker.fish b/contrib/completion/fish/docker.fish index e72fb4e012..80741042dc 100644 --- a/contrib/completion/fish/docker.fish +++ b/contrib/completion/fish/docker.fish @@ -137,6 +137,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: [], 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 memory-swap -d "Total memory usage (memory + swap), set '-1' to disable swap (format: [], 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 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' @@ -328,6 +329,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: [], 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 memory-swap -d "Total memory usage (memory + swap), set '-1' to disable swap (format: [], 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 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' diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index be3c854b78..1e1e211de9 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -1101,7 +1101,7 @@ __docker_service_subcommand() { "($help)--limit-memory=[Limit Memory]:value: " "($help)--log-driver=[Logging driver for service]:logging driver:__docker_log_drivers" "($help)*--log-opt=[Logging driver options]:log driver options:__docker_log_options" - "($help)*--mount=[Attach a mount to the service]:mount: " + "($help)*--mount=[Attach a filesystem mount to the service]:mount: " "($help)*--network=[Network attachments]:network: " "($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" "($help)*"{-p=,--publish=}"[Publish a port as a node port]:port: " @@ -1481,6 +1481,7 @@ __docker_subcommand() { "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_log_drivers" "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_log_options" "($help)--mac-address=[Container MAC address]:MAC address: " + "($help)*--mount=[Attach a filesystem mount to the container]:mount: " "($help)--name=[Container name]:name: " "($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: " diff --git a/docs/reference/commandline/create.md b/docs/reference/commandline/create.md index 784b4940e1..e621efeb1f 100644 --- a/docs/reference/commandline/create.md +++ b/docs/reference/commandline/create.md @@ -78,6 +78,7 @@ Options: --memory-reservation string Memory soft limit --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) + --mount value Attach a filesytem mount to the container (default []) --name string Assign a name to the container --network-alias value Add network-scoped alias for the container (default []) --network string Connect a container to a network (default "default") diff --git a/docs/reference/commandline/run.md b/docs/reference/commandline/run.md index ec6a412009..49009b94b3 100644 --- a/docs/reference/commandline/run.md +++ b/docs/reference/commandline/run.md @@ -84,6 +84,7 @@ Options: --memory-reservation string Memory soft limit --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) + --mount value Attach a filesystem mount to the container (default []) --name string Assign a name to the container --network-alias value Add network-scoped alias for the container (default []) --network string Connect a container to a network @@ -255,6 +256,21 @@ Docker daemon. For in-depth information about volumes, refer to [manage data in containers](https://docs.docker.com/engine/tutorials/dockervolumes/) +### Add bin-mounts or volumes using the --mounts flag + +The `--mounts` 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). + +Examples: + + $ docker run --read-only --mount type=volume,target=/icanwrite busybox touch /icanwrite/here + $ docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh + ### Publish or expose port (-p, --expose) $ docker run -p 127.0.0.1:80:8080 ubuntu bash diff --git a/docs/reference/commandline/service_create.md b/docs/reference/commandline/service_create.md index 3406ad68a0..b16f4c654f 100644 --- a/docs/reference/commandline/service_create.md +++ b/docs/reference/commandline/service_create.md @@ -38,7 +38,7 @@ Options: --log-driver string Logging driver for service --log-opt value Logging driver options (default []) --mode string Service mode (replicated or global) (default "replicated") - --mount value Attach a mount to the service + --mount value Attach a filesystem mount to the service --name string Service name --network value Network attachments (default []) --no-healthcheck Disable any container-specified HEALTHCHECK diff --git a/man/docker-create.1.md b/man/docker-create.1.md index 21cbd9f9d6..fd19ee45c6 100644 --- a/man/docker-create.1.md +++ b/man/docker-create.1.md @@ -53,6 +53,7 @@ docker-create - Create a new container [**--memory-reservation**[=*MEMORY-RESERVATION*]] [**--memory-swap**[=*LIMIT*]] [**--memory-swappiness**[=*MEMORY-SWAPPINESS*]] +[**--mount**[=*MOUNT*]] [**--name**[=*NAME*]] [**--network-alias**[=*[]*]] [**--network**[=*"bridge"*]] diff --git a/man/docker-run.1.md b/man/docker-run.1.md index 0a46f29110..d430ff58a5 100644 --- a/man/docker-run.1.md +++ b/man/docker-run.1.md @@ -55,6 +55,7 @@ docker-run - Run a command in a new container [**--memory-reservation**[=*MEMORY-RESERVATION*]] [**--memory-swap**[=*LIMIT*]] [**--memory-swappiness**[=*MEMORY-SWAPPINESS*]] +[**--mount**[=*MOUNT*]] [**--name**[=*NAME*]] [**--network-alias**[=*[]*]] [**--network**[=*"bridge"*]]