From e6d9b7de649c0b3b59c7d9b698af1c58f6dce289 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 25 Nov 2016 12:38:30 +0000 Subject: [PATCH] cli: remove `--mount` from `docker run` This commit reverts 273eeb813c1db0f42c2ad5e053972eeb00907568 (#26825). For the discussion so far, please refer to #28527. Signed-off-by: Akihiro Suda --- CHANGELOG.md | 1 - contrib/completion/bash/docker | 1 - contrib/completion/fish/docker.fish | 2 - contrib/completion/zsh/_docker | 1 - docs/reference/commandline/create.md | 1 - docs/reference/commandline/run.md | 16 --- integration-cli/docker_cli_run_test.go | 178 ------------------------- man/docker-create.1.md | 1 - man/docker-run.1.md | 1 - runconfig/opts/parse.go | 5 - 10 files changed, 207 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52e26d3396..41fd9bbe7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,7 +97,6 @@ be found. + Add `Isolation` to the /info endpoint [#26255](https://github.com/docker/docker/pull/26255) + Add `userns` to the /info endpoint [#27840](https://github.com/docker/docker/pull/27840) - Do not allow more than one mode be requested at once in the services endpoint [#26643](https://github.com/docker/docker/pull/26643) -+ Add `--mount` flag to `docker create` and `docker run` [#26825](https://github.com/docker/docker/pull/26825)[#28150](https://github.com/docker/docker/pull/28150) + Add capability to /containers/create API to specify mounts in a more granular and safer way [#22373](https://github.com/docker/docker/pull/22373) + Add `--format` flag to `network ls` and `volume ls` [#23475](https://github.com/docker/docker/pull/23475) * Allow the top-level `docker inspect` command to inspect any kind of resource [#23614](https://github.com/docker/docker/pull/23614) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 1d8345595d..03be767914 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1272,7 +1272,6 @@ _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 6630331b7b..2715cb1aa6 100644 --- a/contrib/completion/fish/docker.fish +++ b/contrib/completion/fish/docker.fish @@ -137,7 +137,6 @@ 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' @@ -329,7 +328,6 @@ 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 d361c325c9..a79eaee7d9 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -551,7 +551,6 @@ __docker_container_subcommand() { "($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)--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 9fdfd4c205..0218af3a76 100644 --- a/docs/reference/commandline/create.md +++ b/docs/reference/commandline/create.md @@ -82,7 +82,6 @@ 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 ece12a6462..116b7f7500 100644 --- a/docs/reference/commandline/run.md +++ b/docs/reference/commandline/run.md @@ -92,7 +92,6 @@ 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 @@ -264,21 +263,6 @@ Docker daemon. 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). - -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/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index affd036381..99cef3eeac 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -4572,184 +4572,6 @@ func (s *DockerSuite) TestRunDuplicateMount(c *check.C) { c.Assert(out, checker.Contains, "null") } -func (s *DockerSuite) TestRunMount(c *check.C) { - testRequires(c, DaemonIsLinux, SameHostDaemon, NotUserNamespace) - - // mnt1, mnt2, and testCatFooBar are commonly used in multiple test cases - tmpDir, err := ioutil.TempDir("", "mount") - if err != nil { - c.Fatal(err) - } - defer os.RemoveAll(tmpDir) - mnt1, mnt2 := path.Join(tmpDir, "mnt1"), path.Join(tmpDir, "mnt2") - if err := os.Mkdir(mnt1, 0755); err != nil { - c.Fatal(err) - } - if err := os.Mkdir(mnt2, 0755); err != nil { - c.Fatal(err) - } - if err := ioutil.WriteFile(path.Join(mnt1, "test1"), []byte("test1"), 0644); err != nil { - c.Fatal(err) - } - if err := ioutil.WriteFile(path.Join(mnt2, "test2"), []byte("test2"), 0644); err != nil { - c.Fatal(err) - } - testCatFooBar := func(cName string) error { - out, _ := dockerCmd(c, "exec", cName, "cat", "/foo/test1") - if out != "test1" { - return fmt.Errorf("%s not mounted on /foo", mnt1) - } - out, _ = dockerCmd(c, "exec", cName, "cat", "/bar/test2") - if out != "test2" { - return fmt.Errorf("%s not mounted on /bar", mnt2) - } - return nil - } - - type testCase struct { - equivalents [][]string - valid bool - // fn should be nil if valid==false - fn func(cName string) error - } - cases := []testCase{ - { - equivalents: [][]string{ - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/bar", mnt2), - }, - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,target=/bar", mnt2), - }, - { - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,target=/bar", mnt2), - }, - }, - valid: true, - fn: testCatFooBar, - }, - { - equivalents: [][]string{ - { - "--mount", fmt.Sprintf("type=volume,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,dst=/bar", mnt2), - }, - { - "--mount", fmt.Sprintf("type=volume,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,target=/bar", mnt2), - }, - }, - valid: false, - }, - { - equivalents: [][]string{ - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,dst=/bar", mnt2), - }, - { - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,target=/bar", mnt2), - }, - }, - valid: false, - fn: testCatFooBar, - }, - { - equivalents: [][]string{ - { - "--read-only", - "--mount", "type=volume,dst=/bar", - }, - }, - valid: true, - fn: func(cName string) error { - _, _, err := dockerCmdWithError("exec", cName, "touch", "/bar/icanwritehere") - return err - }, - }, - { - equivalents: [][]string{ - { - "--read-only", - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", "type=volume,dst=/bar", - }, - { - "--read-only", - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", "type=volume,dst=/bar", - }, - }, - valid: true, - fn: func(cName string) error { - out, _ := dockerCmd(c, "exec", cName, "cat", "/foo/test1") - if out != "test1" { - return fmt.Errorf("%s not mounted on /foo", mnt1) - } - _, _, err := dockerCmdWithError("exec", cName, "touch", "/bar/icanwritehere") - return err - }, - }, - { - equivalents: [][]string{ - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt2), - }, - { - "--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,target=/foo", mnt2), - }, - { - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", fmt.Sprintf("type=bind,src=%s,target=/foo", mnt2), - }, - }, - valid: false, - }, - { - equivalents: [][]string{ - { - "--volume", fmt.Sprintf("%s:/foo", mnt1), - "--mount", fmt.Sprintf("type=volume,src=%s,target=/foo", mnt2), - }, - }, - valid: false, - }, - { - equivalents: [][]string{ - { - "--mount", "type=volume,target=/foo", - "--mount", "type=volume,target=/foo", - }, - }, - valid: false, - }, - } - - for i, testCase := range cases { - for j, opts := range testCase.equivalents { - cName := fmt.Sprintf("mount-%d-%d", i, j) - _, _, err := dockerCmdWithError(append([]string{"run", "-i", "-d", "--name", cName}, - append(opts, []string{"busybox", "top"}...)...)...) - if testCase.valid { - c.Assert(err, check.IsNil, - check.Commentf("got error while creating a container with %v (%s)", opts, cName)) - c.Assert(testCase.fn(cName), check.IsNil, - check.Commentf("got error while executing test for %v (%s)", opts, cName)) - dockerCmd(c, "rm", "-f", cName) - } else { - c.Assert(err, checker.NotNil, - check.Commentf("got nil while creating a container with %v (%s)", opts, cName)) - } - } - } -} - func (s *DockerSuite) TestRunWindowsWithCPUCount(c *check.C) { testRequires(c, DaemonIsWindows) diff --git a/man/docker-create.1.md b/man/docker-create.1.md index 8bb162c2c3..a819904efa 100644 --- a/man/docker-create.1.md +++ b/man/docker-create.1.md @@ -56,7 +56,6 @@ 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 061f509c27..a0cbd2ba63 100644 --- a/man/docker-run.1.md +++ b/man/docker-run.1.md @@ -58,7 +58,6 @@ 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"*]] diff --git a/runconfig/opts/parse.go b/runconfig/opts/parse.go index b9631f1a3e..c3aa6e98b1 100644 --- a/runconfig/opts/parse.go +++ b/runconfig/opts/parse.go @@ -25,7 +25,6 @@ type ContainerOptions struct { attach opts.ListOpts volumes opts.ListOpts tmpfs opts.ListOpts - mounts opts.MountOpt blkioWeightDevice WeightdeviceOpt deviceReadBps ThrottledeviceOpt deviceWriteBps ThrottledeviceOpt @@ -217,7 +216,6 @@ func AddFlags(flags *pflag.FlagSet) *ContainerOptions { flags.Var(&copts.tmpfs, "tmpfs", "Mount a tmpfs directory") flags.Var(&copts.volumesFrom, "volumes-from", "Mount volumes from the specified container(s)") flags.VarP(&copts.volumes, "volume", "v", "Bind mount a volume") - flags.Var(&copts.mounts, "mount", "Attach a filesystem mount to the container") // Health-checking flags.StringVar(&copts.healthCmd, "health-cmd", "", "Command to run to check health") @@ -357,8 +355,6 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c } } - mounts := copts.mounts.Value() - var binds []string volumes := copts.volumes.GetMap() // add any bind targets to the list of container volumes @@ -623,7 +619,6 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c Tmpfs: tmpfs, Sysctls: copts.sysctls.GetAll(), Runtime: copts.runtime, - Mounts: mounts, } // only set this value if the user provided the flag, else it should default to nil