@@ -4137,3 +4137,42 @@ func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *check.C) {
41374137 out , _ := dockerCmd (c , "run" , "-v" , "foo:/foo" , "busybox" , "cat" , "/foo/hello" )
41384138 c .Assert (strings .TrimSpace (out ), check .Equals , "hello" )
41394139}
4140+
4141+ func (s * DockerSuite ) TestRunNamedVolumeNotRemoved (c * check.C ) {
4142+ prefix := ""
4143+ if daemonPlatform == "windows" {
4144+ prefix = "c:"
4145+ }
4146+
4147+ dockerCmd (c , "volume" , "create" , "--name" , "test" )
4148+
4149+ dockerCmd (c , "run" , "--rm" , "-v" , "test:" + prefix + "/foo" , "-v" , prefix + "/bar" , "busybox" , "true" )
4150+ dockerCmd (c , "volume" , "inspect" , "test" )
4151+ out , _ := dockerCmd (c , "volume" , "ls" , "-q" )
4152+ c .Assert (strings .TrimSpace (out ), checker .Equals , "test" )
4153+
4154+ dockerCmd (c , "run" , "--name=test" , "-v" , "test:" + prefix + "/foo" , "-v" , prefix + "/bar" , "busybox" , "true" )
4155+ dockerCmd (c , "rm" , "-fv" , "test" )
4156+ dockerCmd (c , "volume" , "inspect" , "test" )
4157+ out , _ = dockerCmd (c , "volume" , "ls" , "-q" )
4158+ c .Assert (strings .TrimSpace (out ), checker .Equals , "test" )
4159+ }
4160+
4161+ func (s * DockerSuite ) TestRunNamedVolumesFromNotRemoved (c * check.C ) {
4162+ prefix := ""
4163+ if daemonPlatform == "windows" {
4164+ prefix = "c:"
4165+ }
4166+
4167+ dockerCmd (c , "volume" , "create" , "--name" , "test" )
4168+ dockerCmd (c , "run" , "--name=parent" , "-v" , "test:" + prefix + "/foo" , "-v" , prefix + "/bar" , "busybox" , "true" )
4169+ dockerCmd (c , "run" , "--name=child" , "--volumes-from=parent" , "busybox" , "true" )
4170+
4171+ // Remove the parent so there are not other references to the volumes
4172+ dockerCmd (c , "rm" , "-f" , "parent" )
4173+ // now remove the child and ensure the named volume (and only the named volume) still exists
4174+ dockerCmd (c , "rm" , "-fv" , "child" )
4175+ dockerCmd (c , "volume" , "inspect" , "test" )
4176+ out , _ := dockerCmd (c , "volume" , "ls" , "-q" )
4177+ c .Assert (strings .TrimSpace (out ), checker .Equals , "test" )
4178+ }
0 commit comments