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 ?
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
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
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 commanddocker run
is used to only START a container for the very first time. To run an existing container what you need isdocker start $container-name
. So much for asking developers to create meaningful/intuitive commands.