mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #15999 from cpuguy83/15994_ext_volume_bind
Set bind driver after volume is created
This commit is contained in:
commit
7c667f9d6e
3 changed files with 19 additions and 1 deletions
|
@ -64,7 +64,7 @@ func createContainerPlatformSpecificSettings(container *Container, config *runco
|
||||||
}
|
}
|
||||||
|
|
||||||
// never attempt to copy existing content in a container FS to a shared volume
|
// never attempt to copy existing content in a container FS to a shared volume
|
||||||
if volumeDriver == volume.DefaultDriverName || volumeDriver == "" {
|
if v.DriverName() == volume.DefaultDriverName {
|
||||||
if err := container.copyImagePathContent(v, destination); err != nil {
|
if err := container.copyImagePathContent(v, destination); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,6 +347,8 @@ func (daemon *Daemon) registerMountPoints(container *Container, hostConfig *runc
|
||||||
}
|
}
|
||||||
bind.Volume = v
|
bind.Volume = v
|
||||||
bind.Source = v.Path()
|
bind.Source = v.Path()
|
||||||
|
// bind.Name is an already existing volume, we need to use that here
|
||||||
|
bind.Driver = v.DriverName()
|
||||||
// Since this is just a named volume and not a typical bind, set to shared mode `z`
|
// Since this is just a named volume and not a typical bind, set to shared mode `z`
|
||||||
if bind.Mode == "" {
|
if bind.Mode == "" {
|
||||||
bind.Mode = "z"
|
bind.Mode = "z"
|
||||||
|
|
|
@ -350,3 +350,19 @@ func (s *DockerExternalVolumeSuite) TestStartExternalVolumeDriverRetryNotImmedia
|
||||||
c.Assert(s.ec.mounts, check.Equals, 1)
|
c.Assert(s.ec.mounts, check.Equals, 1)
|
||||||
c.Assert(s.ec.unmounts, check.Equals, 1)
|
c.Assert(s.ec.unmounts, check.Equals, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerExternalVolumeSuite) TestStartExternalVolumeDriverBindExternalVolume(c *check.C) {
|
||||||
|
dockerCmd(c, "volume", "create", "-d", "test-external-volume-driver", "--name", "foo")
|
||||||
|
dockerCmd(c, "run", "-d", "--name", "testing", "-v", "foo:/bar", "busybox", "top")
|
||||||
|
|
||||||
|
var mounts []struct {
|
||||||
|
Name string
|
||||||
|
Driver string
|
||||||
|
}
|
||||||
|
out, err := inspectFieldJSON("testing", "Mounts")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
c.Assert(json.NewDecoder(strings.NewReader(out)).Decode(&mounts), check.IsNil)
|
||||||
|
c.Assert(len(mounts), check.Equals, 1, check.Commentf(out))
|
||||||
|
c.Assert(mounts[0].Name, check.Equals, "foo")
|
||||||
|
c.Assert(mounts[0].Driver, check.Equals, "test-external-volume-driver")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue