New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jul 7, 2017

Conversation

Projects
None yet
5 participants
@yaocaigen
Contributor

yaocaigen commented Jul 4, 2017

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

- What I did
Fix a bug:
Description:

  1. start a container
    docker run busybox
  2. run docker rename command concurrently
    #!/bin/bash
    for((i=0;i<10;i++))
    do
    docker rename efbf7ff32533 name${i} &
    done
    
  3. container has multi names
    # docker ps --no-trunc -a
    CONTAINER ID                                                       IMAGE           COMMAND             CREATED             STATUS                       PORTS               NAMES                                                           
    efbf7ff32533151babb878769e47fc5c33cd85b2afbfa52ef29f4cb16929e64c   busybox         "/bin/sh"           7 minutes ago       Exited (0) 7 minutes ago                         name2,name4,name1,name8,name5,name6,name3,name7,name9                                     
    
  4. run docker ps and docker inspect, container name is different
    # docker ps --format "table {{.Names}}" -a
    NAMES
    name2
    # docker inspect --format {{.Name}} name2
    /name9
    

- How I did it
Every docker rename operation should release newest container name, so container should get locked before get container name.
- How to verify it

  1. start a container
  2. run docker rename command concurrently
  3. run docker ps and docker inspect, container name is the same

Signed-off-by: Yang Pengfei yangpengfei4@huawei.com

@AkihiroSuda

This comment has been minimized.

Show comment
Hide comment
@AkihiroSuda
Member

AkihiroSuda commented Jul 4, 2017

@cpuguy83

LGTM

Fix run `docker rename <container-id> new_name` concurrently, the con…
…tainer 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>
@yaocaigen

This comment has been minimized.

Show comment
Hide comment
@yaocaigen

yaocaigen Jul 6, 2017

Contributor

@fabiokung PTAL

Contributor

yaocaigen commented Jul 6, 2017

@fabiokung PTAL

@fabiokung

This comment has been minimized.

Show comment
Hide comment
@fabiokung

fabiokung Jul 6, 2017

Contributor

LGTM, thanks!

Contributor

fabiokung commented Jul 6, 2017

LGTM, thanks!

@AkihiroSuda

LGTM

@AkihiroSuda AkihiroSuda merged commit 8e3555f into moby:master Jul 7, 2017

6 checks passed

dco-signed All commits are signed
experimental Jenkins build Docker-PRs-experimental 35468 has succeeded
Details
janky Jenkins build Docker-PRs 44080 has succeeded
Details
powerpc Jenkins build Docker-PRs-powerpc 4452 has succeeded
Details
windowsRS1 Jenkins build Docker-PRs-WoW-RS1 15421 has succeeded
Details
z Jenkins build Docker-PRs-s390x 4155 has succeeded
Details

@yaocaigen yaocaigen deleted the yaocaigen:fix_container_multi_names branch Jul 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment