Merge pull request #22103 from coolljt0725/fix_22093

Fix docker create with duplicate volume failed to remove
Upstream-commit: edcc9577bf95c2eeaa15955e7b1c00a18cec7cb6
Component: engine
This commit is contained in:
Vincent Demeester
2016-05-30 15:57:13 +02:00
2 changed files with 33 additions and 1 deletions
+12 -1
View File
@@ -65,9 +65,20 @@ func (m mounts) parts(i int) int {
// 2. Select the volumes mounted from another containers. Overrides previously configured mount point destination.
// 3. Select the bind mounts set by the client. Overrides previously configured mount point destinations.
// 4. Cleanup old volumes that are about to be reassigned.
func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig) error {
func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig) (retErr error) {
binds := map[string]bool{}
mountPoints := map[string]*volume.MountPoint{}
defer func() {
// clean up the container mountpoints once return with error
if retErr != nil {
for _, m := range mountPoints {
if m.Volume == nil {
continue
}
daemon.volumes.Dereference(m.Volume, container.ID)
}
}
}()
// 1. Read already configured mount points.
for name, point := range container.MountPoints {