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 ?
You can remove it with command
sudo docker rm YOUR_CONTAINER_ID
, then run a new container withsudo docker run ...
; or restart an existing container withsudo docker start YOUR_CONTAINER_ID
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 withdocker 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
.You have 2 options to fix this...
Remove previous container using that name, with the command
docker rm $(docker ps -aq --filter name=myContainerName)
OR
--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).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:
e.g.
Sadly it's used almost randomly in the examples from the docs
Cause
A container with the same name is still existing.
Solution
To reuse the same container name, delete the existing container by:
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 :To show containers in all states and find out if a container name is taken, use:
Here what i did, it works fine.
step 1:(it lists docker container with its name)
step 2: