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>

Akihiro Suda authored on 2016/11/25 21:38:30
Showing 10 changed files
... ...
@@ -97,7 +97,6 @@ be found.
97 97
 + Add `Isolation` to the /info endpoint [#26255](https://github.com/docker/docker/pull/26255)
98 98
 + Add `userns` to the /info endpoint [#27840](https://github.com/docker/docker/pull/27840)
99 99
 - Do not allow more than one mode be requested at once in the services endpoint [#26643](https://github.com/docker/docker/pull/26643)
100
-+ 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)
101 100
 + Add capability to /containers/create API to specify mounts in a more granular and safer way [#22373](https://github.com/docker/docker/pull/22373)
102 101
 + Add `--format` flag to `network ls` and `volume ls` [#23475](https://github.com/docker/docker/pull/23475)
103 102
 * Allow the top-level `docker inspect` command to inspect any kind of resource [#23614](https://github.com/docker/docker/pull/23614)
... ...
@@ -1272,7 +1272,6 @@ _docker_container_run() {
1272 1272
 		--memory-swap
1273 1273
 		--memory-swappiness
1274 1274
 		--memory-reservation
1275
-		--mount
1276 1275
 		--name
1277 1276
 		--network
1278 1277
 		--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
... ...
@@ -264,21 +263,6 @@ Docker daemon.
264 264
 
265 265
 For in-depth information about volumes, refer to [manage data in containers](https://docs.docker.com/engine/tutorials/dockervolumes/)
266 266
 
267
-### Add bind-mounts or volumes using the --mount flag
268
-
269
-The `--mount` flag allows you to mount volumes, host-directories and `tmpfs`
270
-mounts in a container.
271
-
272
-The `--mount` flag supports most options that are supported by the `-v` or the
273
-`--volume` flag, but uses a different syntax. For in-depth information on the
274
-`--mount` flag, and a comparison between `--volume` and `--mount`, refer to
275
-the [service create command reference](service_create.md#add-bind-mounts-or-volumes).
276
-
277
-Examples:
278
-
279
-    $ docker run --read-only --mount type=volume,target=/icanwrite busybox touch /icanwrite/here
280
-    $ docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh
281
-
282 267
 ### Publish or expose port (-p, --expose)
283 268
 
284 269
     $ docker run -p 127.0.0.1:80:8080 ubuntu bash
... ...
@@ -4572,184 +4572,6 @@ func (s *DockerSuite) TestRunDuplicateMount(c *check.C) {
4572 4572
 	c.Assert(out, checker.Contains, "null")
4573 4573
 }
4574 4574
 
4575
-func (s *DockerSuite) TestRunMount(c *check.C) {
4576
-	testRequires(c, DaemonIsLinux, SameHostDaemon, NotUserNamespace)
4577
-
4578
-	// mnt1, mnt2, and testCatFooBar are commonly used in multiple test cases
4579
-	tmpDir, err := ioutil.TempDir("", "mount")
4580
-	if err != nil {
4581
-		c.Fatal(err)
4582
-	}
4583
-	defer os.RemoveAll(tmpDir)
4584
-	mnt1, mnt2 := path.Join(tmpDir, "mnt1"), path.Join(tmpDir, "mnt2")
4585
-	if err := os.Mkdir(mnt1, 0755); err != nil {
4586
-		c.Fatal(err)
4587
-	}
4588
-	if err := os.Mkdir(mnt2, 0755); err != nil {
4589
-		c.Fatal(err)
4590
-	}
4591
-	if err := ioutil.WriteFile(path.Join(mnt1, "test1"), []byte("test1"), 0644); err != nil {
4592
-		c.Fatal(err)
4593
-	}
4594
-	if err := ioutil.WriteFile(path.Join(mnt2, "test2"), []byte("test2"), 0644); err != nil {
4595
-		c.Fatal(err)
4596
-	}
4597
-	testCatFooBar := func(cName string) error {
4598
-		out, _ := dockerCmd(c, "exec", cName, "cat", "/foo/test1")
4599
-		if out != "test1" {
4600
-			return fmt.Errorf("%s not mounted on /foo", mnt1)
4601
-		}
4602
-		out, _ = dockerCmd(c, "exec", cName, "cat", "/bar/test2")
4603
-		if out != "test2" {
4604
-			return fmt.Errorf("%s not mounted on /bar", mnt2)
4605
-		}
4606
-		return nil
4607
-	}
4608
-
4609
-	type testCase struct {
4610
-		equivalents [][]string
4611
-		valid       bool
4612
-		// fn should be nil if valid==false
4613
-		fn func(cName string) error
4614
-	}
4615
-	cases := []testCase{
4616
-		{
4617
-			equivalents: [][]string{
4618
-				{
4619
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4620
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/bar", mnt2),
4621
-				},
4622
-				{
4623
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4624
-					"--mount", fmt.Sprintf("type=bind,src=%s,target=/bar", mnt2),
4625
-				},
4626
-				{
4627
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4628
-					"--mount", fmt.Sprintf("type=bind,src=%s,target=/bar", mnt2),
4629
-				},
4630
-			},
4631
-			valid: true,
4632
-			fn:    testCatFooBar,
4633
-		},
4634
-		{
4635
-			equivalents: [][]string{
4636
-				{
4637
-					"--mount", fmt.Sprintf("type=volume,src=%s,dst=/foo", mnt1),
4638
-					"--mount", fmt.Sprintf("type=volume,src=%s,dst=/bar", mnt2),
4639
-				},
4640
-				{
4641
-					"--mount", fmt.Sprintf("type=volume,src=%s,dst=/foo", mnt1),
4642
-					"--mount", fmt.Sprintf("type=volume,src=%s,target=/bar", mnt2),
4643
-				},
4644
-			},
4645
-			valid: false,
4646
-		},
4647
-		{
4648
-			equivalents: [][]string{
4649
-				{
4650
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4651
-					"--mount", fmt.Sprintf("type=volume,src=%s,dst=/bar", mnt2),
4652
-				},
4653
-				{
4654
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4655
-					"--mount", fmt.Sprintf("type=volume,src=%s,target=/bar", mnt2),
4656
-				},
4657
-			},
4658
-			valid: false,
4659
-			fn:    testCatFooBar,
4660
-		},
4661
-		{
4662
-			equivalents: [][]string{
4663
-				{
4664
-					"--read-only",
4665
-					"--mount", "type=volume,dst=/bar",
4666
-				},
4667
-			},
4668
-			valid: true,
4669
-			fn: func(cName string) error {
4670
-				_, _, err := dockerCmdWithError("exec", cName, "touch", "/bar/icanwritehere")
4671
-				return err
4672
-			},
4673
-		},
4674
-		{
4675
-			equivalents: [][]string{
4676
-				{
4677
-					"--read-only",
4678
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4679
-					"--mount", "type=volume,dst=/bar",
4680
-				},
4681
-				{
4682
-					"--read-only",
4683
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4684
-					"--mount", "type=volume,dst=/bar",
4685
-				},
4686
-			},
4687
-			valid: true,
4688
-			fn: func(cName string) error {
4689
-				out, _ := dockerCmd(c, "exec", cName, "cat", "/foo/test1")
4690
-				if out != "test1" {
4691
-					return fmt.Errorf("%s not mounted on /foo", mnt1)
4692
-				}
4693
-				_, _, err := dockerCmdWithError("exec", cName, "touch", "/bar/icanwritehere")
4694
-				return err
4695
-			},
4696
-		},
4697
-		{
4698
-			equivalents: [][]string{
4699
-				{
4700
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4701
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt2),
4702
-				},
4703
-				{
4704
-					"--mount", fmt.Sprintf("type=bind,src=%s,dst=/foo", mnt1),
4705
-					"--mount", fmt.Sprintf("type=bind,src=%s,target=/foo", mnt2),
4706
-				},
4707
-				{
4708
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4709
-					"--mount", fmt.Sprintf("type=bind,src=%s,target=/foo", mnt2),
4710
-				},
4711
-			},
4712
-			valid: false,
4713
-		},
4714
-		{
4715
-			equivalents: [][]string{
4716
-				{
4717
-					"--volume", fmt.Sprintf("%s:/foo", mnt1),
4718
-					"--mount", fmt.Sprintf("type=volume,src=%s,target=/foo", mnt2),
4719
-				},
4720
-			},
4721
-			valid: false,
4722
-		},
4723
-		{
4724
-			equivalents: [][]string{
4725
-				{
4726
-					"--mount", "type=volume,target=/foo",
4727
-					"--mount", "type=volume,target=/foo",
4728
-				},
4729
-			},
4730
-			valid: false,
4731
-		},
4732
-	}
4733
-
4734
-	for i, testCase := range cases {
4735
-		for j, opts := range testCase.equivalents {
4736
-			cName := fmt.Sprintf("mount-%d-%d", i, j)
4737
-			_, _, err := dockerCmdWithError(append([]string{"run", "-i", "-d", "--name", cName},
4738
-				append(opts, []string{"busybox", "top"}...)...)...)
4739
-			if testCase.valid {
4740
-				c.Assert(err, check.IsNil,
4741
-					check.Commentf("got error while creating a container with %v (%s)", opts, cName))
4742
-				c.Assert(testCase.fn(cName), check.IsNil,
4743
-					check.Commentf("got error while executing test for %v (%s)", opts, cName))
4744
-				dockerCmd(c, "rm", "-f", cName)
4745
-			} else {
4746
-				c.Assert(err, checker.NotNil,
4747
-					check.Commentf("got nil while creating a container with %v (%s)", opts, cName))
4748
-			}
4749
-		}
4750
-	}
4751
-}
4752
-
4753 4575
 func (s *DockerSuite) TestRunWindowsWithCPUCount(c *check.C) {
4754 4576
 	testRequires(c, DaemonIsWindows)
4755 4577
 
... ...
@@ -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