mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #14498 from calavera/fix_volume_from_references
Fix volumes-from mount references.
This commit is contained in:
commit
37771c122b
2 changed files with 27 additions and 4 deletions
|
@ -191,11 +191,16 @@ func (daemon *Daemon) registerMountPoints(container *Container, hostConfig *runc
|
|||
}
|
||||
|
||||
for _, m := range c.MountPoints {
|
||||
cp := m
|
||||
cp.RW = m.RW && mode != "ro"
|
||||
cp := &mountPoint{
|
||||
Name: m.Name,
|
||||
Source: m.Source,
|
||||
RW: m.RW && mode != "ro",
|
||||
Driver: m.Driver,
|
||||
Destination: m.Destination,
|
||||
}
|
||||
|
||||
if len(m.Source) == 0 {
|
||||
v, err := createVolume(m.Name, m.Driver)
|
||||
if len(cp.Source) == 0 {
|
||||
v, err := createVolume(cp.Name, cp.Driver)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -3233,3 +3233,21 @@ func (s *DockerSuite) TestRunCapAddCHOWN(c *check.C) {
|
|||
c.Fatalf("expected output ok received %s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/docker/docker/pull/14498
|
||||
func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *check.C) {
|
||||
dockerCmd(c, "run", "--name", "parent", "-v", "/test", "busybox", "true")
|
||||
dockerCmd(c, "run", "--volumes-from", "parent:ro", "--name", "test-volumes-1", "busybox", "true")
|
||||
dockerCmd(c, "run", "--volumes-from", "parent:rw", "--name", "test-volumes-2", "busybox", "true")
|
||||
|
||||
testRO, err := inspectFieldMap("test-volumes-1", ".VolumesRW", "/test")
|
||||
c.Assert(err, check.IsNil)
|
||||
if testRO != "false" {
|
||||
c.Fatalf("Expected RO volume was RW")
|
||||
}
|
||||
testRW, err := inspectFieldMap("test-volumes-2", ".VolumesRW", "/test")
|
||||
c.Assert(err, check.IsNil)
|
||||
if testRW != "true" {
|
||||
c.Fatalf("Expected RW volume was RO")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue