docker run -> name is already in use by container












220















Running the docker registry with below command always throws an error:



dev:tmp me$ docker run 
-d --name registry-v1
-e SETTINGS_FLAVOR=local
-e STORAGE_PATH=/registry
-e SEARCH_BACKEND=sqlalchemy
-e LOGLEVEL=DEBUG
-p 5000:5000
registry:0.9.1
Error response from daemon: Conflict. The name "registry-v1" is already in use by container f9e5798a82e0. You have to delete (or rename) that container to be able to reuse that name.


How to prevent this error ?










share|improve this question





























    220















    Running the docker registry with below command always throws an error:



    dev:tmp me$ docker run 
    -d --name registry-v1
    -e SETTINGS_FLAVOR=local
    -e STORAGE_PATH=/registry
    -e SEARCH_BACKEND=sqlalchemy
    -e LOGLEVEL=DEBUG
    -p 5000:5000
    registry:0.9.1
    Error response from daemon: Conflict. The name "registry-v1" is already in use by container f9e5798a82e0. You have to delete (or rename) that container to be able to reuse that name.


    How to prevent this error ?










    share|improve this question



























      220












      220








      220


      31






      Running the docker registry with below command always throws an error:



      dev:tmp me$ docker run 
      -d --name registry-v1
      -e SETTINGS_FLAVOR=local
      -e STORAGE_PATH=/registry
      -e SEARCH_BACKEND=sqlalchemy
      -e LOGLEVEL=DEBUG
      -p 5000:5000
      registry:0.9.1
      Error response from daemon: Conflict. The name "registry-v1" is already in use by container f9e5798a82e0. You have to delete (or rename) that container to be able to reuse that name.


      How to prevent this error ?










      share|improve this question
















      Running the docker registry with below command always throws an error:



      dev:tmp me$ docker run 
      -d --name registry-v1
      -e SETTINGS_FLAVOR=local
      -e STORAGE_PATH=/registry
      -e SEARCH_BACKEND=sqlalchemy
      -e LOGLEVEL=DEBUG
      -p 5000:5000
      registry:0.9.1
      Error response from daemon: Conflict. The name "registry-v1" is already in use by container f9e5798a82e0. You have to delete (or rename) that container to be able to reuse that name.


      How to prevent this error ?







      docker






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 19 '16 at 3:04









      Scott Stensland

      16.1k75972




      16.1k75972










      asked Jul 29 '15 at 10:26









      RubytasticRubytastic

      4,3751472154




      4,3751472154
























          9 Answers
          9






          active

          oldest

          votes


















          276














          I got confused by this also. There are two commands relevant here:



          docker run Run a command in a new container



          docker start Start one or more stopped containers






          share|improve this answer



















          • 4





            This is the answer I was looking for in order to re-run a Docker container. Thanks!

            – isapir
            Jul 5 '16 at 15:47






          • 58





            So it is also important to use docker ps -a to see all containers in this case.

            – Sławosz
            Oct 3 '16 at 10:48











          • You can also use restart command.

            – thekevshow
            Oct 17 '17 at 14:55






          • 19





            so docker run actually should be docker create .....

            – eMPee584
            Jan 5 '18 at 20:20






          • 1





            yes, docker start -a container-name is the command you can use to start a container that has been created with docker run. Note the -a flag which is shorthand for --attach. This way the container is started in the foreground, just like when you use docker run (which runs a container in the foreground by default).

            – Krzysztof Wołowski
            Jan 9 at 21:38





















          128














          That means you have already started a container in the past with the parameter docker run --name registry-v1 ....



          You need to delete that first before you can re-create a container with the same name with docker rm registry-v1. When that container is sill running you need to stop it first before you can delete it with docker stop registry-v1. Or simply choose a different name for the new container.



          To get a list of existing containers and their names simply invoke docker ps -a.






          share|improve this answer



















          • 3





            But why are the ones that are stopped for? Or whats good if they are still there if they are stopped?

            – mskw
            Jan 17 '16 at 5:56






          • 1





            So you can run them later without recreating them

            – Scott Stensland
            Jan 19 '16 at 3:06






          • 2





            So you are basically saying "so that you can RUN the image once (i.e. produce the container then run the command in it), then START the container as many times as you wish". But why would we need to RUN something just once? Without even persisting the possible changes that "something" made to the container (remember, docker container state changes are lost unless committed).

            – Maksim Gumerov
            Apr 23 '16 at 10:09






          • 13





            If you know the name of your container you can remove it using this shortcut docker rm $(docker ps -aq --filter name=myContainerName)

            – Jujhar Singh
            May 6 '16 at 15:48






          • 1





            I had one stopped because I suspended my machine while it was running. I had started it with --rm but in this case, it was stopped (and with my limited skills, at least, there doesn't seem to be a way to resume it interactively).

            – tripleee
            Nov 11 '16 at 4:47



















          58














          Here what i did, it works fine.



          step 1:(it lists docker container with its name)



          docker ps -a


          step 2:



          docker rm name_of_the_docker_container





          share|improve this answer































            22














            You have 2 options to fix this...





            1. Remove previous container using that name, with the command docker rm $(docker ps -aq --filter name=myContainerName)



              OR



            2. Rename current container to a different name i.e change this portion --name registry-v1 to something like --name myAnotherContainerName


            You are getting this error because that container name ( i.e registry-v1) was used by another container in the past...even though that container may have exited i.e (currently not in use).






            share|improve this answer

































              10














              Just to explain what others are saying (it took me some time to understand): simply put when you see this error, it means you already have a container and what you have to do is run it. While intuitively docker run is supposed to run, it doesn't. The command docker run is used to only START a container for the very first time. To run an existing container what you need is docker start $container-name. So much for asking developers to create meaningful/intuitive commands.






              share|improve this answer

































                9














                You can remove it with command sudo docker rm YOUR_CONTAINER_ID, then run a new container with sudo docker run ...;
                or restart an existing container with sudo docker start YOUR_CONTAINER_ID






                share|improve this answer

































                  8














                  Cause



                  A container with the same name is still existing.



                  Solution



                  To reuse the same container name, delete the existing container by:



                  docker rm <container name>


                  Explanation



                  Containers can exist in following states, during which the container name can't be used for another container:




                  • created

                  • restarting

                  • running

                  • paused

                  • exited

                  • dead


                  You can see containers in running state by using :



                  docker ps


                  To show containers in all states and find out if a container name is taken, use:



                  docker ps -a





                  share|improve this answer































                    5














                    When you are building a new image you often want to run a new container each time and with the same name. I found the easiest way was to start the container with the --rm option:



                    --rm        Automatically remove the container when it exits


                    e.g.



                    docker run --name my-micro-service --rm <image>


                    Sadly it's used almost randomly in the examples from the docs






                    share|improve this answer































                      4














                      I'm just learning docker and this got me as well. I stopped the container with that name already and therefore I thought I could run a new container with that name.



                      Not the case. Just because the container is stopped, doesn't mean it can't be started again, and it keeps all the same parameters that it was created with (including the name).



                      when I ran docker ps -a that's when I saw all the dummy test containers I created while I was playing around.



                      No problem, since I don't want those any more I just did docker rm containername at which point my new container was allowed to run with the old name.



                      Ah, and now that I finish writing this answer, I see Slawosz's comment on Walt Howard's answer above suggesting the use of docker ps -a






                      share|improve this answer























                        Your Answer






                        StackExchange.ifUsing("editor", function () {
                        StackExchange.using("externalEditor", function () {
                        StackExchange.using("snippets", function () {
                        StackExchange.snippets.init();
                        });
                        });
                        }, "code-snippets");

                        StackExchange.ready(function() {
                        var channelOptions = {
                        tags: "".split(" "),
                        id: "1"
                        };
                        initTagRenderer("".split(" "), "".split(" "), channelOptions);

                        StackExchange.using("externalEditor", function() {
                        // Have to fire editor after snippets, if snippets enabled
                        if (StackExchange.settings.snippets.snippetsEnabled) {
                        StackExchange.using("snippets", function() {
                        createEditor();
                        });
                        }
                        else {
                        createEditor();
                        }
                        });

                        function createEditor() {
                        StackExchange.prepareEditor({
                        heartbeatType: 'answer',
                        autoActivateHeartbeat: false,
                        convertImagesToLinks: true,
                        noModals: true,
                        showLowRepImageUploadWarning: true,
                        reputationToPostImages: 10,
                        bindNavPrevention: true,
                        postfix: "",
                        imageUploader: {
                        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                        allowUrls: true
                        },
                        onDemand: true,
                        discardSelector: ".discard-answer"
                        ,immediatelyShowMarkdownHelp:true
                        });


                        }
                        });














                        draft saved

                        draft discarded


















                        StackExchange.ready(
                        function () {
                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31697828%2fdocker-run-name-is-already-in-use-by-container%23new-answer', 'question_page');
                        }
                        );

                        Post as a guest















                        Required, but never shown

























                        9 Answers
                        9






                        active

                        oldest

                        votes








                        9 Answers
                        9






                        active

                        oldest

                        votes









                        active

                        oldest

                        votes






                        active

                        oldest

                        votes









                        276














                        I got confused by this also. There are two commands relevant here:



                        docker run Run a command in a new container



                        docker start Start one or more stopped containers






                        share|improve this answer



















                        • 4





                          This is the answer I was looking for in order to re-run a Docker container. Thanks!

                          – isapir
                          Jul 5 '16 at 15:47






                        • 58





                          So it is also important to use docker ps -a to see all containers in this case.

                          – Sławosz
                          Oct 3 '16 at 10:48











                        • You can also use restart command.

                          – thekevshow
                          Oct 17 '17 at 14:55






                        • 19





                          so docker run actually should be docker create .....

                          – eMPee584
                          Jan 5 '18 at 20:20






                        • 1





                          yes, docker start -a container-name is the command you can use to start a container that has been created with docker run. Note the -a flag which is shorthand for --attach. This way the container is started in the foreground, just like when you use docker run (which runs a container in the foreground by default).

                          – Krzysztof Wołowski
                          Jan 9 at 21:38


















                        276














                        I got confused by this also. There are two commands relevant here:



                        docker run Run a command in a new container



                        docker start Start one or more stopped containers






                        share|improve this answer



















                        • 4





                          This is the answer I was looking for in order to re-run a Docker container. Thanks!

                          – isapir
                          Jul 5 '16 at 15:47






                        • 58





                          So it is also important to use docker ps -a to see all containers in this case.

                          – Sławosz
                          Oct 3 '16 at 10:48











                        • You can also use restart command.

                          – thekevshow
                          Oct 17 '17 at 14:55






                        • 19





                          so docker run actually should be docker create .....

                          – eMPee584
                          Jan 5 '18 at 20:20






                        • 1





                          yes, docker start -a container-name is the command you can use to start a container that has been created with docker run. Note the -a flag which is shorthand for --attach. This way the container is started in the foreground, just like when you use docker run (which runs a container in the foreground by default).

                          – Krzysztof Wołowski
                          Jan 9 at 21:38
















                        276












                        276








                        276







                        I got confused by this also. There are two commands relevant here:



                        docker run Run a command in a new container



                        docker start Start one or more stopped containers






                        share|improve this answer













                        I got confused by this also. There are two commands relevant here:



                        docker run Run a command in a new container



                        docker start Start one or more stopped containers







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Mar 4 '16 at 18:30









                        Walt HowardWalt Howard

                        3,0441910




                        3,0441910








                        • 4





                          This is the answer I was looking for in order to re-run a Docker container. Thanks!

                          – isapir
                          Jul 5 '16 at 15:47






                        • 58





                          So it is also important to use docker ps -a to see all containers in this case.

                          – Sławosz
                          Oct 3 '16 at 10:48











                        • You can also use restart command.

                          – thekevshow
                          Oct 17 '17 at 14:55






                        • 19





                          so docker run actually should be docker create .....

                          – eMPee584
                          Jan 5 '18 at 20:20






                        • 1





                          yes, docker start -a container-name is the command you can use to start a container that has been created with docker run. Note the -a flag which is shorthand for --attach. This way the container is started in the foreground, just like when you use docker run (which runs a container in the foreground by default).

                          – Krzysztof Wołowski
                          Jan 9 at 21:38
















                        • 4





                          This is the answer I was looking for in order to re-run a Docker container. Thanks!

                          – isapir
                          Jul 5 '16 at 15:47






                        • 58





                          So it is also important to use docker ps -a to see all containers in this case.

                          – Sławosz
                          Oct 3 '16 at 10:48











                        • You can also use restart command.

                          – thekevshow
                          Oct 17 '17 at 14:55






                        • 19





                          so docker run actually should be docker create .....

                          – eMPee584
                          Jan 5 '18 at 20:20






                        • 1





                          yes, docker start -a container-name is the command you can use to start a container that has been created with docker run. Note the -a flag which is shorthand for --attach. This way the container is started in the foreground, just like when you use docker run (which runs a container in the foreground by default).

                          – Krzysztof Wołowski
                          Jan 9 at 21:38










                        4




                        4





                        This is the answer I was looking for in order to re-run a Docker container. Thanks!

                        – isapir
                        Jul 5 '16 at 15:47





                        This is the answer I was looking for in order to re-run a Docker container. Thanks!

                        – isapir
                        Jul 5 '16 at 15:47




                        58




                        58





                        So it is also important to use docker ps -a to see all containers in this case.

                        – Sławosz
                        Oct 3 '16 at 10:48





                        So it is also important to use docker ps -a to see all containers in this case.

                        – Sławosz
                        Oct 3 '16 at 10:48













                        You can also use restart command.

                        – thekevshow
                        Oct 17 '17 at 14:55





                        You can also use restart command.

                        – thekevshow
                        Oct 17 '17 at 14:55




                        19




                        19





                        so docker run actually should be docker create .....

                        – eMPee584
                        Jan 5 '18 at 20:20





                        so docker run actually should be docker create .....

                        – eMPee584
                        Jan 5 '18 at 20:20




                        1




                        1





                        yes, docker start -a container-name is the command you can use to start a container that has been created with docker run. Note the -a flag which is shorthand for --attach. This way the container is started in the foreground, just like when you use docker run (which runs a container in the foreground by default).

                        – Krzysztof Wołowski
                        Jan 9 at 21:38







                        yes, docker start -a container-name is the command you can use to start a container that has been created with docker run. Note the -a flag which is shorthand for --attach. This way the container is started in the foreground, just like when you use docker run (which runs a container in the foreground by default).

                        – Krzysztof Wołowski
                        Jan 9 at 21:38















                        128














                        That means you have already started a container in the past with the parameter docker run --name registry-v1 ....



                        You need to delete that first before you can re-create a container with the same name with docker rm registry-v1. When that container is sill running you need to stop it first before you can delete it with docker stop registry-v1. Or simply choose a different name for the new container.



                        To get a list of existing containers and their names simply invoke docker ps -a.






                        share|improve this answer



















                        • 3





                          But why are the ones that are stopped for? Or whats good if they are still there if they are stopped?

                          – mskw
                          Jan 17 '16 at 5:56






                        • 1





                          So you can run them later without recreating them

                          – Scott Stensland
                          Jan 19 '16 at 3:06






                        • 2





                          So you are basically saying "so that you can RUN the image once (i.e. produce the container then run the command in it), then START the container as many times as you wish". But why would we need to RUN something just once? Without even persisting the possible changes that "something" made to the container (remember, docker container state changes are lost unless committed).

                          – Maksim Gumerov
                          Apr 23 '16 at 10:09






                        • 13





                          If you know the name of your container you can remove it using this shortcut docker rm $(docker ps -aq --filter name=myContainerName)

                          – Jujhar Singh
                          May 6 '16 at 15:48






                        • 1





                          I had one stopped because I suspended my machine while it was running. I had started it with --rm but in this case, it was stopped (and with my limited skills, at least, there doesn't seem to be a way to resume it interactively).

                          – tripleee
                          Nov 11 '16 at 4:47
















                        128














                        That means you have already started a container in the past with the parameter docker run --name registry-v1 ....



                        You need to delete that first before you can re-create a container with the same name with docker rm registry-v1. When that container is sill running you need to stop it first before you can delete it with docker stop registry-v1. Or simply choose a different name for the new container.



                        To get a list of existing containers and their names simply invoke docker ps -a.






                        share|improve this answer



















                        • 3





                          But why are the ones that are stopped for? Or whats good if they are still there if they are stopped?

                          – mskw
                          Jan 17 '16 at 5:56






                        • 1





                          So you can run them later without recreating them

                          – Scott Stensland
                          Jan 19 '16 at 3:06






                        • 2





                          So you are basically saying "so that you can RUN the image once (i.e. produce the container then run the command in it), then START the container as many times as you wish". But why would we need to RUN something just once? Without even persisting the possible changes that "something" made to the container (remember, docker container state changes are lost unless committed).

                          – Maksim Gumerov
                          Apr 23 '16 at 10:09






                        • 13





                          If you know the name of your container you can remove it using this shortcut docker rm $(docker ps -aq --filter name=myContainerName)

                          – Jujhar Singh
                          May 6 '16 at 15:48






                        • 1





                          I had one stopped because I suspended my machine while it was running. I had started it with --rm but in this case, it was stopped (and with my limited skills, at least, there doesn't seem to be a way to resume it interactively).

                          – tripleee
                          Nov 11 '16 at 4:47














                        128












                        128








                        128







                        That means you have already started a container in the past with the parameter docker run --name registry-v1 ....



                        You need to delete that first before you can re-create a container with the same name with docker rm registry-v1. When that container is sill running you need to stop it first before you can delete it with docker stop registry-v1. Or simply choose a different name for the new container.



                        To get a list of existing containers and their names simply invoke docker ps -a.






                        share|improve this answer













                        That means you have already started a container in the past with the parameter docker run --name registry-v1 ....



                        You need to delete that first before you can re-create a container with the same name with docker rm registry-v1. When that container is sill running you need to stop it first before you can delete it with docker stop registry-v1. Or simply choose a different name for the new container.



                        To get a list of existing containers and their names simply invoke docker ps -a.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jul 29 '15 at 10:34









                        h3nrikh3nrik

                        25.5k73245




                        25.5k73245








                        • 3





                          But why are the ones that are stopped for? Or whats good if they are still there if they are stopped?

                          – mskw
                          Jan 17 '16 at 5:56






                        • 1





                          So you can run them later without recreating them

                          – Scott Stensland
                          Jan 19 '16 at 3:06






                        • 2





                          So you are basically saying "so that you can RUN the image once (i.e. produce the container then run the command in it), then START the container as many times as you wish". But why would we need to RUN something just once? Without even persisting the possible changes that "something" made to the container (remember, docker container state changes are lost unless committed).

                          – Maksim Gumerov
                          Apr 23 '16 at 10:09






                        • 13





                          If you know the name of your container you can remove it using this shortcut docker rm $(docker ps -aq --filter name=myContainerName)

                          – Jujhar Singh
                          May 6 '16 at 15:48






                        • 1





                          I had one stopped because I suspended my machine while it was running. I had started it with --rm but in this case, it was stopped (and with my limited skills, at least, there doesn't seem to be a way to resume it interactively).

                          – tripleee
                          Nov 11 '16 at 4:47














                        • 3





                          But why are the ones that are stopped for? Or whats good if they are still there if they are stopped?

                          – mskw
                          Jan 17 '16 at 5:56






                        • 1





                          So you can run them later without recreating them

                          – Scott Stensland
                          Jan 19 '16 at 3:06






                        • 2





                          So you are basically saying "so that you can RUN the image once (i.e. produce the container then run the command in it), then START the container as many times as you wish". But why would we need to RUN something just once? Without even persisting the possible changes that "something" made to the container (remember, docker container state changes are lost unless committed).

                          – Maksim Gumerov
                          Apr 23 '16 at 10:09






                        • 13





                          If you know the name of your container you can remove it using this shortcut docker rm $(docker ps -aq --filter name=myContainerName)

                          – Jujhar Singh
                          May 6 '16 at 15:48






                        • 1





                          I had one stopped because I suspended my machine while it was running. I had started it with --rm but in this case, it was stopped (and with my limited skills, at least, there doesn't seem to be a way to resume it interactively).

                          – tripleee
                          Nov 11 '16 at 4:47








                        3




                        3





                        But why are the ones that are stopped for? Or whats good if they are still there if they are stopped?

                        – mskw
                        Jan 17 '16 at 5:56





                        But why are the ones that are stopped for? Or whats good if they are still there if they are stopped?

                        – mskw
                        Jan 17 '16 at 5:56




                        1




                        1





                        So you can run them later without recreating them

                        – Scott Stensland
                        Jan 19 '16 at 3:06





                        So you can run them later without recreating them

                        – Scott Stensland
                        Jan 19 '16 at 3:06




                        2




                        2





                        So you are basically saying "so that you can RUN the image once (i.e. produce the container then run the command in it), then START the container as many times as you wish". But why would we need to RUN something just once? Without even persisting the possible changes that "something" made to the container (remember, docker container state changes are lost unless committed).

                        – Maksim Gumerov
                        Apr 23 '16 at 10:09





                        So you are basically saying "so that you can RUN the image once (i.e. produce the container then run the command in it), then START the container as many times as you wish". But why would we need to RUN something just once? Without even persisting the possible changes that "something" made to the container (remember, docker container state changes are lost unless committed).

                        – Maksim Gumerov
                        Apr 23 '16 at 10:09




                        13




                        13





                        If you know the name of your container you can remove it using this shortcut docker rm $(docker ps -aq --filter name=myContainerName)

                        – Jujhar Singh
                        May 6 '16 at 15:48





                        If you know the name of your container you can remove it using this shortcut docker rm $(docker ps -aq --filter name=myContainerName)

                        – Jujhar Singh
                        May 6 '16 at 15:48




                        1




                        1





                        I had one stopped because I suspended my machine while it was running. I had started it with --rm but in this case, it was stopped (and with my limited skills, at least, there doesn't seem to be a way to resume it interactively).

                        – tripleee
                        Nov 11 '16 at 4:47





                        I had one stopped because I suspended my machine while it was running. I had started it with --rm but in this case, it was stopped (and with my limited skills, at least, there doesn't seem to be a way to resume it interactively).

                        – tripleee
                        Nov 11 '16 at 4:47











                        58














                        Here what i did, it works fine.



                        step 1:(it lists docker container with its name)



                        docker ps -a


                        step 2:



                        docker rm name_of_the_docker_container





                        share|improve this answer




























                          58














                          Here what i did, it works fine.



                          step 1:(it lists docker container with its name)



                          docker ps -a


                          step 2:



                          docker rm name_of_the_docker_container





                          share|improve this answer


























                            58












                            58








                            58







                            Here what i did, it works fine.



                            step 1:(it lists docker container with its name)



                            docker ps -a


                            step 2:



                            docker rm name_of_the_docker_container





                            share|improve this answer













                            Here what i did, it works fine.



                            step 1:(it lists docker container with its name)



                            docker ps -a


                            step 2:



                            docker rm name_of_the_docker_container






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 12 '18 at 13:06









                            thavaammthavaamm

                            1,2771112




                            1,2771112























                                22














                                You have 2 options to fix this...





                                1. Remove previous container using that name, with the command docker rm $(docker ps -aq --filter name=myContainerName)



                                  OR



                                2. Rename current container to a different name i.e change this portion --name registry-v1 to something like --name myAnotherContainerName


                                You are getting this error because that container name ( i.e registry-v1) was used by another container in the past...even though that container may have exited i.e (currently not in use).






                                share|improve this answer






























                                  22














                                  You have 2 options to fix this...





                                  1. Remove previous container using that name, with the command docker rm $(docker ps -aq --filter name=myContainerName)



                                    OR



                                  2. Rename current container to a different name i.e change this portion --name registry-v1 to something like --name myAnotherContainerName


                                  You are getting this error because that container name ( i.e registry-v1) was used by another container in the past...even though that container may have exited i.e (currently not in use).






                                  share|improve this answer




























                                    22












                                    22








                                    22







                                    You have 2 options to fix this...





                                    1. Remove previous container using that name, with the command docker rm $(docker ps -aq --filter name=myContainerName)



                                      OR



                                    2. Rename current container to a different name i.e change this portion --name registry-v1 to something like --name myAnotherContainerName


                                    You are getting this error because that container name ( i.e registry-v1) was used by another container in the past...even though that container may have exited i.e (currently not in use).






                                    share|improve this answer















                                    You have 2 options to fix this...





                                    1. Remove previous container using that name, with the command docker rm $(docker ps -aq --filter name=myContainerName)



                                      OR



                                    2. Rename current container to a different name i.e change this portion --name registry-v1 to something like --name myAnotherContainerName


                                    You are getting this error because that container name ( i.e registry-v1) was used by another container in the past...even though that container may have exited i.e (currently not in use).







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Dec 29 '17 at 13:51

























                                    answered Aug 14 '17 at 9:39









                                    Edwin IkechukwuEdwin Ikechukwu

                                    1,9472123




                                    1,9472123























                                        10














                                        Just to explain what others are saying (it took me some time to understand): simply put when you see this error, it means you already have a container and what you have to do is run it. While intuitively docker run is supposed to run, it doesn't. The command docker run is used to only START a container for the very first time. To run an existing container what you need is docker start $container-name. So much for asking developers to create meaningful/intuitive commands.






                                        share|improve this answer






























                                          10














                                          Just to explain what others are saying (it took me some time to understand): simply put when you see this error, it means you already have a container and what you have to do is run it. While intuitively docker run is supposed to run, it doesn't. The command docker run is used to only START a container for the very first time. To run an existing container what you need is docker start $container-name. So much for asking developers to create meaningful/intuitive commands.






                                          share|improve this answer




























                                            10












                                            10








                                            10







                                            Just to explain what others are saying (it took me some time to understand): simply put when you see this error, it means you already have a container and what you have to do is run it. While intuitively docker run is supposed to run, it doesn't. The command docker run is used to only START a container for the very first time. To run an existing container what you need is docker start $container-name. So much for asking developers to create meaningful/intuitive commands.






                                            share|improve this answer















                                            Just to explain what others are saying (it took me some time to understand): simply put when you see this error, it means you already have a container and what you have to do is run it. While intuitively docker run is supposed to run, it doesn't. The command docker run is used to only START a container for the very first time. To run an existing container what you need is docker start $container-name. So much for asking developers to create meaningful/intuitive commands.







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Nov 20 '18 at 3:16

























                                            answered Sep 11 '18 at 23:05









                                            mithunpaulmithunpaul

                                            781711




                                            781711























                                                9














                                                You can remove it with command sudo docker rm YOUR_CONTAINER_ID, then run a new container with sudo docker run ...;
                                                or restart an existing container with sudo docker start YOUR_CONTAINER_ID






                                                share|improve this answer






























                                                  9














                                                  You can remove it with command sudo docker rm YOUR_CONTAINER_ID, then run a new container with sudo docker run ...;
                                                  or restart an existing container with sudo docker start YOUR_CONTAINER_ID






                                                  share|improve this answer




























                                                    9












                                                    9








                                                    9







                                                    You can remove it with command sudo docker rm YOUR_CONTAINER_ID, then run a new container with sudo docker run ...;
                                                    or restart an existing container with sudo docker start YOUR_CONTAINER_ID






                                                    share|improve this answer















                                                    You can remove it with command sudo docker rm YOUR_CONTAINER_ID, then run a new container with sudo docker run ...;
                                                    or restart an existing container with sudo docker start YOUR_CONTAINER_ID







                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited Mar 5 '18 at 4:43









                                                    Edwin Ikechukwu

                                                    1,9472123




                                                    1,9472123










                                                    answered Nov 21 '17 at 7:12









                                                    dongleidonglei

                                                    9914




                                                    9914























                                                        8














                                                        Cause



                                                        A container with the same name is still existing.



                                                        Solution



                                                        To reuse the same container name, delete the existing container by:



                                                        docker rm <container name>


                                                        Explanation



                                                        Containers can exist in following states, during which the container name can't be used for another container:




                                                        • created

                                                        • restarting

                                                        • running

                                                        • paused

                                                        • exited

                                                        • dead


                                                        You can see containers in running state by using :



                                                        docker ps


                                                        To show containers in all states and find out if a container name is taken, use:



                                                        docker ps -a





                                                        share|improve this answer




























                                                          8














                                                          Cause



                                                          A container with the same name is still existing.



                                                          Solution



                                                          To reuse the same container name, delete the existing container by:



                                                          docker rm <container name>


                                                          Explanation



                                                          Containers can exist in following states, during which the container name can't be used for another container:




                                                          • created

                                                          • restarting

                                                          • running

                                                          • paused

                                                          • exited

                                                          • dead


                                                          You can see containers in running state by using :



                                                          docker ps


                                                          To show containers in all states and find out if a container name is taken, use:



                                                          docker ps -a





                                                          share|improve this answer


























                                                            8












                                                            8








                                                            8







                                                            Cause



                                                            A container with the same name is still existing.



                                                            Solution



                                                            To reuse the same container name, delete the existing container by:



                                                            docker rm <container name>


                                                            Explanation



                                                            Containers can exist in following states, during which the container name can't be used for another container:




                                                            • created

                                                            • restarting

                                                            • running

                                                            • paused

                                                            • exited

                                                            • dead


                                                            You can see containers in running state by using :



                                                            docker ps


                                                            To show containers in all states and find out if a container name is taken, use:



                                                            docker ps -a





                                                            share|improve this answer













                                                            Cause



                                                            A container with the same name is still existing.



                                                            Solution



                                                            To reuse the same container name, delete the existing container by:



                                                            docker rm <container name>


                                                            Explanation



                                                            Containers can exist in following states, during which the container name can't be used for another container:




                                                            • created

                                                            • restarting

                                                            • running

                                                            • paused

                                                            • exited

                                                            • dead


                                                            You can see containers in running state by using :



                                                            docker ps


                                                            To show containers in all states and find out if a container name is taken, use:



                                                            docker ps -a






                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Apr 10 '18 at 11:14









                                                            Roderick JonssonRoderick Jonsson

                                                            9818




                                                            9818























                                                                5














                                                                When you are building a new image you often want to run a new container each time and with the same name. I found the easiest way was to start the container with the --rm option:



                                                                --rm        Automatically remove the container when it exits


                                                                e.g.



                                                                docker run --name my-micro-service --rm <image>


                                                                Sadly it's used almost randomly in the examples from the docs






                                                                share|improve this answer




























                                                                  5














                                                                  When you are building a new image you often want to run a new container each time and with the same name. I found the easiest way was to start the container with the --rm option:



                                                                  --rm        Automatically remove the container when it exits


                                                                  e.g.



                                                                  docker run --name my-micro-service --rm <image>


                                                                  Sadly it's used almost randomly in the examples from the docs






                                                                  share|improve this answer


























                                                                    5












                                                                    5








                                                                    5







                                                                    When you are building a new image you often want to run a new container each time and with the same name. I found the easiest way was to start the container with the --rm option:



                                                                    --rm        Automatically remove the container when it exits


                                                                    e.g.



                                                                    docker run --name my-micro-service --rm <image>


                                                                    Sadly it's used almost randomly in the examples from the docs






                                                                    share|improve this answer













                                                                    When you are building a new image you often want to run a new container each time and with the same name. I found the easiest way was to start the container with the --rm option:



                                                                    --rm        Automatically remove the container when it exits


                                                                    e.g.



                                                                    docker run --name my-micro-service --rm <image>


                                                                    Sadly it's used almost randomly in the examples from the docs







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Jun 29 '18 at 14:43









                                                                    MartinMartin

                                                                    589815




                                                                    589815























                                                                        4














                                                                        I'm just learning docker and this got me as well. I stopped the container with that name already and therefore I thought I could run a new container with that name.



                                                                        Not the case. Just because the container is stopped, doesn't mean it can't be started again, and it keeps all the same parameters that it was created with (including the name).



                                                                        when I ran docker ps -a that's when I saw all the dummy test containers I created while I was playing around.



                                                                        No problem, since I don't want those any more I just did docker rm containername at which point my new container was allowed to run with the old name.



                                                                        Ah, and now that I finish writing this answer, I see Slawosz's comment on Walt Howard's answer above suggesting the use of docker ps -a






                                                                        share|improve this answer




























                                                                          4














                                                                          I'm just learning docker and this got me as well. I stopped the container with that name already and therefore I thought I could run a new container with that name.



                                                                          Not the case. Just because the container is stopped, doesn't mean it can't be started again, and it keeps all the same parameters that it was created with (including the name).



                                                                          when I ran docker ps -a that's when I saw all the dummy test containers I created while I was playing around.



                                                                          No problem, since I don't want those any more I just did docker rm containername at which point my new container was allowed to run with the old name.



                                                                          Ah, and now that I finish writing this answer, I see Slawosz's comment on Walt Howard's answer above suggesting the use of docker ps -a






                                                                          share|improve this answer


























                                                                            4












                                                                            4








                                                                            4







                                                                            I'm just learning docker and this got me as well. I stopped the container with that name already and therefore I thought I could run a new container with that name.



                                                                            Not the case. Just because the container is stopped, doesn't mean it can't be started again, and it keeps all the same parameters that it was created with (including the name).



                                                                            when I ran docker ps -a that's when I saw all the dummy test containers I created while I was playing around.



                                                                            No problem, since I don't want those any more I just did docker rm containername at which point my new container was allowed to run with the old name.



                                                                            Ah, and now that I finish writing this answer, I see Slawosz's comment on Walt Howard's answer above suggesting the use of docker ps -a






                                                                            share|improve this answer













                                                                            I'm just learning docker and this got me as well. I stopped the container with that name already and therefore I thought I could run a new container with that name.



                                                                            Not the case. Just because the container is stopped, doesn't mean it can't be started again, and it keeps all the same parameters that it was created with (including the name).



                                                                            when I ran docker ps -a that's when I saw all the dummy test containers I created while I was playing around.



                                                                            No problem, since I don't want those any more I just did docker rm containername at which point my new container was allowed to run with the old name.



                                                                            Ah, and now that I finish writing this answer, I see Slawosz's comment on Walt Howard's answer above suggesting the use of docker ps -a







                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered Mar 13 '18 at 15:03









                                                                            matrixuglymatrixugly

                                                                            1,43121737




                                                                            1,43121737






























                                                                                draft saved

                                                                                draft discarded




















































                                                                                Thanks for contributing an answer to Stack Overflow!


                                                                                • Please be sure to answer the question. Provide details and share your research!

                                                                                But avoid



                                                                                • Asking for help, clarification, or responding to other answers.

                                                                                • Making statements based on opinion; back them up with references or personal experience.


                                                                                To learn more, see our tips on writing great answers.




                                                                                draft saved


                                                                                draft discarded














                                                                                StackExchange.ready(
                                                                                function () {
                                                                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31697828%2fdocker-run-name-is-already-in-use-by-container%23new-answer', 'question_page');
                                                                                }
                                                                                );

                                                                                Post as a guest















                                                                                Required, but never shown





















































                                                                                Required, but never shown














                                                                                Required, but never shown












                                                                                Required, but never shown







                                                                                Required, but never shown

































                                                                                Required, but never shown














                                                                                Required, but never shown












                                                                                Required, but never shown







                                                                                Required, but never shown







                                                                                這個網誌中的熱門文章

                                                                                Tangent Lines Diagram Along Smooth Curve

                                                                                Yusuf al-Mu'taman ibn Hud

                                                                                Zucchini