mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #4989 from alexlarsson/fix-volumes-from
Fix --volumes-from mount failure
This commit is contained in:
commit
5844920185
2 changed files with 24 additions and 1 deletions
|
@ -272,6 +272,24 @@ func TestDockerRunWithVolumesAsFiles(t *testing.T) {
|
|||
logDone("run - regression test for #4741 - volumes from as files")
|
||||
}
|
||||
|
||||
// Regression test for #4979
|
||||
func TestDockerRunWithVolumesFromExited(t *testing.T) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "--name", "test-data", "--volume", "/some/dir", "busybox", "touch", "/some/dir/file")
|
||||
out, stderr, exitCode, err := runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil && exitCode != 0 {
|
||||
t.Fatal("1", out, stderr, err)
|
||||
}
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "run", "--volumes-from", "test-data", "busybox", "cat", "/some/dir/file")
|
||||
out, stderr, exitCode, err = runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil && exitCode != 0 {
|
||||
t.Fatal("2", out, stderr, err)
|
||||
}
|
||||
deleteAllContainers()
|
||||
|
||||
logDone("run - regression test for #4979 - volumes-from on exited container")
|
||||
}
|
||||
|
||||
// Regression test for #4830
|
||||
func TestDockerRunWithRelativePath(t *testing.T) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-v", "tmp:/other-tmp", "busybox", "true")
|
||||
|
|
|
@ -81,9 +81,14 @@ func applyVolumesFrom(container *Container) error {
|
|||
|
||||
c := container.runtime.Get(specParts[0])
|
||||
if c == nil {
|
||||
return fmt.Errorf("Container %s not found. Impossible to mount its volumes", container.ID)
|
||||
return fmt.Errorf("Container %s not found. Impossible to mount its volumes", specParts[0])
|
||||
}
|
||||
|
||||
if err := c.Mount(); err != nil {
|
||||
return fmt.Errorf("Container %s failed to mount. Impossible to mount its volumes", specParts[0])
|
||||
}
|
||||
defer c.Unmount()
|
||||
|
||||
for volPath, id := range c.Volumes {
|
||||
if _, exists := container.Volumes[volPath]; exists {
|
||||
continue
|
||||
|
|
Loading…
Add table
Reference in a new issue