Browse code

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 <suda.akihiro@lab.ntt.co.jp>
(cherry picked from commit e6d9b7de649c0b3b59c7d9b698af1c58f6dce289)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>

Akihiro Suda authored on 2016/11/25 21:38:30
Showing 10 changed files
... ...
@@ -99,7 +99,6 @@ be found.
99 99
 + Add `Isolation` to the /info endpoint [#26255](https://github.com/docker/docker/pull/26255)
100 100
 + Add `userns` to the /info endpoint [#27840](https://github.com/docker/docker/pull/27840)
101 101
 - Do not allow more than one mode be requested at once in the services endpoint [#26643](https://github.com/docker/docker/pull/26643)
102
-+ 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)
103 102
 + Add capability to /containers/create API to specify mounts in a more granular and safer way [#22373](https://github.com/docker/docker/pull/22373)
104 103
 + Add `--format` flag to `network ls` and `volume ls` [#23475](https://github.com/docker/docker/pull/23475)
105 104
 * Allow the top-level `docker inspect` command to inspect any kind of resource [#23614](https://github.com/docker/docker/pull/23614)
... ...
@@ -1309,7 +1309,6 @@ _docker_container_run() {
1309 1309
 		--memory-swap
1310 1310
 		--memory-swappiness
1311 1311
 		--memory-reservation
1312
-		--mount
1313 1312
 		--name
1314 1313
 		--network
1315 1314
 		--network-alias
... ...
@@ -137,7 +137,6 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l link -d 'Add
137 137
 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)'
138 138
 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)'
139 139
 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)"
140
-complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l mount -d 'Attach a filesystem mount to the container'
141 140
 complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l name -d 'Assign a name to the container'
142 141
 complete -c docker -A -f -n '__fish_seen_subcommand_from create' -l net -d 'Set the Network mode for the container'
143 142
 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
329 329
 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)'
330 330
 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)'
331 331
 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)"
332
-complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l mount -d 'Attach a filesystem mount to the container'
333 332
 complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l name -d 'Assign a name to the container'
334 333
 complete -c docker -A -f -n '__fish_seen_subcommand_from run' -l net -d 'Set the Network mode for the container'
335 334
 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'
... ...
@@ -551,7 +551,6 @@ __docker_container_subcommand() {
551 551
         "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers"
552 552
         "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_complete_log_options"
553 553
         "($help)--mac-address=[Container MAC address]:MAC address: "
554
-        "($help)*--mount=[Attach a filesystem mount to the container]:mount: "
555 554
         "($help)--name=[Container name]:name: "
556 555
         "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)"
557 556
         "($help)*--network-alias=[Add network-scoped alias for the container]:alias: "
... ...
@@ -82,7 +82,6 @@ Options:
82 82
       --memory-reservation string   Memory soft limit
83 83
       --memory-swap string          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
84 84
       --memory-swappiness int       Tune container memory swappiness (0 to 100) (default -1)
85
-      --mount value                 Attach a filesytem mount to the container (default [])
86 85
       --name string                 Assign a name to the container
87 86
       --network-alias value         Add network-scoped alias for the container (default [])
88 87
       --network string              Connect a container to a network (default "default")
... ...
@@ -92,7 +92,6 @@ Options:
92 92
       --memory-reservation string   Memory soft limit
93 93
       --memory-swap string          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
94 94
       --memory-swappiness int       Tune container memory swappiness (0 to 100) (default -1)
95
-      --mount value                 Attach a filesystem mount to the container (default [])
96 95
       --name string                 Assign a name to the container
97 96
       --network-alias value         Add network-scoped alias for the container (default [])
98 97
       --network string              Connect a container to a network
... ...
@@ -284,21 +283,6 @@ of a bind mount must be a local directory, not a file.
284 284
 
285 285
 For in-depth information about volumes, refer to [manage data in containers](https://docs.docker.com/engine/tutorials/dockervolumes/)
286 286
 
287
-### Add bin-mounts or volumes using the --mount flag
288
-
289
-The `--mount` flag allows you to mount volumes, host-directories and `tmpfs`
290
-mounts in a container.
291
-
292
-The `--mount` flag supports most options that are supported by the `-v` or the
293
-`--volume` flag, but uses a different syntax. For in-depth information on the
294
-`--mount` flag, and a comparison between `--volume` and `--mount`, refer to
295
-the [service create command reference](service_create.md#add-bind-mounts-or-volumes).
296
-
297
-Examples:
298
-
299
-    $ docker run --read-only --mount type=volume,target=/icanwrite busybox touch /icanwrite/here
300
-    $ docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh
301
-
302 287
 ### Publish or expose port (-p, --expose)
303 288
 
304 289
     $ docker run -p 127.0.0.1:80:8080 ubuntu bash
... ...
@@ -4590,184 +4590,6 @@ func (s *DockerSuite) TestRunDuplicateMount(c *check.C) {
4590 4590
 	c.Assert(out, checker.Contains, "null")
4591 4591
 }
4592 4592
 
4593
-func (s *DockerSuite) TestRunMount(c *check.C) {
4594
-	testRequires(c, DaemonIsLinux, SameHostDaemon, NotUserNamespace)
4595
-
4596
-	// mnt1, mnt2, and testCatFooBar are commonly used in multiple test cases
4597
-	tmpDir, err := ioutil.TempDir("", "mount")
4598
-	if err != nil {
4599
-		c.Fatal(err)
4600
-	}
4601
-	defer os.RemoveAll(tmpDir)
4602
-	mnt1, mnt2 := path.Join(tmpDir, "mnt1"), path.Join(tmpDir, "mnt2")
4603
-	if err := os.Mkdir(mnt1, 0755); err != nil {
4604
-		c.Fatal(err)
4605
-	}
4606
-	if err := os.Mkdir(mnt2, 0755); err != nil {
4607
-		c.Fatal(err)
4608
-	}
4609
-	if err := ioutil.WriteFile(path.Join(mnt1, "test1"), []byte("test1"), 0644); err != nil {
4610
-		c.Fatal(err)
4611
-	}
4612
-	if err := ioutil.WriteFile(path.Join(mnt2, "test2"), []byte("test2"), 0644); err != nil {
4613
-		c.Fatal(err)
4614
-	}
4615
-	testCatFooBar := func(cName string) error {
4616
-		out, _ := dockerCmd(c, "exec", cName, "cat", "/foo/test1")
4617
-		if out != "test1" {
4618
-			return fmt.Errorf("%s not mounted on /foo", mnt1)
4619
-		}
4620
-		out, _ = dockerCmd(c, "exec", cName, "cat", "/bar/test2")
4621
-		if out != "test2" {
4622
-			return fmt.Errorf("%s not mounted on /bar", mnt2)
4623
-		}
4624
-		return nil
4625
-	}
4626
-
4627
-	type testCase struct {
4628
-		equivalents [][]string
4629
-		valid       bool
4630
-		// fn should be nil if valid==false
4631
-		fn func(cName string) error
4632
-	}
4633
-	cases := []testCase{
4634
-		{
4635
-			equivalents: [][]string{
4636
-				{
4637
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4638
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/bar", mnt2),
4639
-				},
4640
-				{
4641
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4642
-					"--mount", fmt.Sprintf("type=bind,src=%s,target=/bar", mnt2),
4643
-				},
4644
-				{
4645
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4646
-					"--mount", fmt.Sprintf("type=bind,src=%s,target=/bar", mnt2),
4647
-				},
4648
-			},
4649
-			valid: true,
4650
-			fn:    testCatFooBar,
4651
-		},
4652
-		{
4653
-			equivalents: [][]string{
4654
-				{
4655
-					"--mount", fmt.Sprintf("type=volume,src=%s,dst=/foo", mnt1),
4656
-					"--mount", fmt.Sprintf("type=volume,src=%s,dst=/bar", mnt2),
4657
-				},
4658
-				{
4659
-					"--mount", fmt.Sprintf("type=volume,src=%s,dst=/foo", mnt1),
4660
-					"--mount", fmt.Sprintf("type=volume,src=%s,target=/bar", mnt2),
4661
-				},
4662
-			},
4663
-			valid: false,
4664
-		},
4665
-		{
4666
-			equivalents: [][]string{
4667
-				{
4668
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4669
-					"--mount", fmt.Sprintf("type=volume,src=%s,dst=/bar", mnt2),
4670
-				},
4671
-				{
4672
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4673
-					"--mount", fmt.Sprintf("type=volume,src=%s,target=/bar", mnt2),
4674
-				},
4675
-			},
4676
-			valid: false,
4677
-			fn:    testCatFooBar,
4678
-		},
4679
-		{
4680
-			equivalents: [][]string{
4681
-				{
4682
-					"--read-only",
4683
-					"--mount", "type=volume,dst=/bar",
4684
-				},
4685
-			},
4686
-			valid: true,
4687
-			fn: func(cName string) error {
4688
-				_, _, err := dockerCmdWithError("exec", cName, "touch", "/bar/icanwritehere")
4689
-				return err
4690
-			},
4691
-		},
4692
-		{
4693
-			equivalents: [][]string{
4694
-				{
4695
-					"--read-only",
4696
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4697
-					"--mount", "type=volume,dst=/bar",
4698
-				},
4699
-				{
4700
-					"--read-only",
4701
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4702
-					"--mount", "type=volume,dst=/bar",
4703
-				},
4704
-			},
4705
-			valid: true,
4706
-			fn: func(cName string) error {
4707
-				out, _ := dockerCmd(c, "exec", cName, "cat", "/foo/test1")
4708
-				if out != "test1" {
4709
-					return fmt.Errorf("%s not mounted on /foo", mnt1)
4710
-				}
4711
-				_, _, err := dockerCmdWithError("exec", cName, "touch", "/bar/icanwritehere")
4712
-				return err
4713
-			},
4714
-		},
4715
-		{
4716
-			equivalents: [][]string{
4717
-				{
4718
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4719
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt2),
4720
-				},
4721
-				{
4722
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4723
-					"--mount", fmt.Sprintf("type=bind,src=%s,target=/foo", mnt2),
4724
-				},
4725
-				{
4726
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4727
-					"--mount", fmt.Sprintf("type=bind,src=%s,target=/foo", mnt2),
4728
-				},
4729
-			},
4730
-			valid: false,
4731
-		},
4732
-		{
4733
-			equivalents: [][]string{
4734
-				{
4735
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4736
-					"--mount", fmt.Sprintf("type=volume,src=%s,target=/foo", mnt2),
4737
-				},
4738
-			},
4739
-			valid: false,
4740
-		},
4741
-		{
4742
-			equivalents: [][]string{
4743
-				{
4744
-					"--mount", "type=volume,target=/foo",
4745
-					"--mount", "type=volume,target=/foo",
4746
-				},
4747
-			},
4748
-			valid: false,
4749
-		},
4750
-	}
4751
-
4752
-	for i, testCase := range cases {
4753
-		for j, opts := range testCase.equivalents {
4754
-			cName := fmt.Sprintf("mount-%d-%d", i, j)
4755
-			_, _, err := dockerCmdWithError(append([]string{"run", "-i", "-d", "--name", cName},
4756
-				append(opts, []string{"busybox", "top"}...)...)...)
4757
-			if testCase.valid {
4758
-				c.Assert(err, check.IsNil,
4759
-					check.Commentf("got error while creating a container with %v (%s)", opts, cName))
4760
-				c.Assert(testCase.fn(cName), check.IsNil,
4761
-					check.Commentf("got error while executing test for %v (%s)", opts, cName))
4762
-				dockerCmd(c, "rm", "-f", cName)
4763
-			} else {
4764
-				c.Assert(err, checker.NotNil,
4765
-					check.Commentf("got nil while creating a container with %v (%s)", opts, cName))
4766
-			}
4767
-		}
4768
-	}
4769
-}
4770
-
4771 4593
 func (s *DockerSuite) TestRunWindowsWithCPUCount(c *check.C) {
4772 4594
 	testRequires(c, DaemonIsWindows)
4773 4595
 
... ...
@@ -56,7 +56,6 @@ docker-create - Create a new container
56 56
 [**--memory-reservation**[=*MEMORY-RESERVATION*]]
57 57
 [**--memory-swap**[=*LIMIT*]]
58 58
 [**--memory-swappiness**[=*MEMORY-SWAPPINESS*]]
59
-[**--mount**[=*MOUNT*]]
60 59
 [**--name**[=*NAME*]]
61 60
 [**--network-alias**[=*[]*]]
62 61
 [**--network**[=*"bridge"*]]
... ...
@@ -58,7 +58,6 @@ docker-run - Run a command in a new container
58 58
 [**--memory-reservation**[=*MEMORY-RESERVATION*]]
59 59
 [**--memory-swap**[=*LIMIT*]]
60 60
 [**--memory-swappiness**[=*MEMORY-SWAPPINESS*]]
61
-[**--mount**[=*MOUNT*]]
62 61
 [**--name**[=*NAME*]]
63 62
 [**--network-alias**[=*[]*]]
64 63
 [**--network**[=*"bridge"*]]
... ...
@@ -25,7 +25,6 @@ type ContainerOptions struct {
25 25
 	attach             opts.ListOpts
26 26
 	volumes            opts.ListOpts
27 27
 	tmpfs              opts.ListOpts
28
-	mounts             opts.MountOpt
29 28
 	blkioWeightDevice  WeightdeviceOpt
30 29
 	deviceReadBps      ThrottledeviceOpt
31 30
 	deviceWriteBps     ThrottledeviceOpt
... ...
@@ -217,7 +216,6 @@ func AddFlags(flags *pflag.FlagSet) *ContainerOptions {
217 217
 	flags.Var(&copts.tmpfs, "tmpfs", "Mount a tmpfs directory")
218 218
 	flags.Var(&copts.volumesFrom, "volumes-from", "Mount volumes from the specified container(s)")
219 219
 	flags.VarP(&copts.volumes, "volume", "v", "Bind mount a volume")
220
-	flags.Var(&copts.mounts, "mount", "Attach a filesystem mount to the container")
221 220
 
222 221
 	// Health-checking
223 222
 	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
357 357
 		}
358 358
 	}
359 359
 
360
-	mounts := copts.mounts.Value()
361
-
362 360
 	var binds []string
363 361
 	volumes := copts.volumes.GetMap()
364 362
 	// add any bind targets to the list of container volumes
... ...
@@ -623,7 +619,6 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c
623 623
 		Tmpfs:          tmpfs,
624 624
 		Sysctls:        copts.sysctls.GetAll(),
625 625
 		Runtime:        copts.runtime,
626
-		Mounts:         mounts,
627 626
 	}
628 627
 
629 628
 	// only set this value if the user provided the flag, else it should default to nil