1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix run docker rename <container-id> new_name concurrently, the container will have multi names

When run `docker rename <container-id> new_name` concurrently, every operation will release
container's old name. So container will have multi new names reserve in nameIndex.

Signed-off-by: Yang Pengfei <yangpengfei4@huawei.com>
This commit is contained in:
Yang Pengfei 2017-07-04 23:35:58 +08:00
parent a9358df62c
commit cc2340689c

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) {