Merge pull request #28838 from AkihiroSuda/remove-run-mount
[Revert #26825] cli: remove `--mount` from `docker run`
This commit is contained in:
commit
caaa52c124
10 changed files with 0 additions and 207 deletions
|
@ -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)
|
||||
|
|
|
@ -1313,7 +1313,6 @@ _docker_container_run() {
|
|||
--memory-swap
|
||||
--memory-swappiness
|
||||
--memory-reservation
|
||||
--mount
|
||||
--name
|
||||
--network
|
||||
--network-alias
|
||||
|
|
|
@ -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: <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 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 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: <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 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 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'
|
||||
|
|
|
@ -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: "
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
@ -284,21 +283,6 @@ of a bind mount must be a local directory, not a file.
|
|||
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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"*]]
|
||||
|
|
|
@ -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"*]]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue