diff --git a/container.go b/container.go index 44797e6724..326c0c55fe 100644 --- a/container.go +++ b/container.go @@ -587,7 +587,7 @@ func (container *Container) Start(hostConfig *HostConfig) error { } for volPath, id := range c.Volumes { if _, exists := container.Volumes[volPath]; exists { - return fmt.Errorf("The requested volume %s overlap one of the volume of the container %s", volPath, c.ID) + continue } if err := os.MkdirAll(path.Join(container.RootfsPath(), volPath), 0755); err != nil { return nil @@ -602,10 +602,12 @@ func (container *Container) Start(hostConfig *HostConfig) error { // Create the requested volumes if they don't exist for volPath := range container.Config.Volumes { volPath = path.Clean(volPath) - // If an external bind is defined for this volume, use that as a source + // Skip existing volumes if _, exists := container.Volumes[volPath]; exists { - // Skip existing mounts - } else if bindMap, exists := binds[volPath]; exists { + continue + } + // If an external bind is defined for this volume, use that as a source + if bindMap, exists := binds[volPath]; exists { container.Volumes[volPath] = bindMap.SrcPath if strings.ToLower(bindMap.Mode) == "rw" { container.VolumesRW[volPath] = true diff --git a/container_test.go b/container_test.go index c4f2193733..644e1c058c 100644 --- a/container_test.go +++ b/container_test.go @@ -1333,6 +1333,12 @@ func TestVolumesFromWithVolumes(t *testing.T) { if container.Volumes["/test"] != container2.Volumes["/test"] { t.Fail() } + + // Ensure it restarts successfully + _, err = container2.Output() + if err != nil { + t.Fatal(err) + } } func TestOnlyLoopbackExistsWhenUsingDisableNetworkOption(t *testing.T) {