Merge pull request #33940 from yaocaigen/fix_container_multi_names

Fix run `docker rename <container-id> new_name` concurrently, the container will have multi names
Upstream-commit: 8e3555f8539d91f530f895e19a51db14f1ca93fb
Component: engine
This commit is contained in:
Akihiro Suda
2017-07-07 10:58:01 +09:00
committed by GitHub
+3 -3
View File
@@ -32,6 +32,9 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error {
return err
}
container.Lock()
defer container.Unlock()
oldName = container.Name
oldIsAnonymousEndpoint := container.NetworkSettings.IsAnonymousEndpoint
@@ -39,9 +42,6 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error {
return errors.New("Renaming a container with the same name as its current name")
}
container.Lock()
defer container.Unlock()
links := map[string]*dockercontainer.Container{}
for k, v := range daemon.linkIndex.children(container) {
if !strings.HasPrefix(k, oldName) {