I'm running the intro tutorial for Docker on Mac and am getting an error as follows:
docker run -d -p 80:80 --name docker-tutorial docker101tutorial
docker: Error response from daemon: Conflict. The container name "/docker-tutorial" is already in use by container "c5a91ef51a529a00dcbef180560dc2b392f3d9ab05b8c29fa1bf640d64271de7". You have to remove (or rename) that container to be able to reuse that name. See 'docker run --help'.
Can you advise on this error — it seems that I would need to delete a prior container? But I don't believe I created one.
Can anyone please advise as to how to troubleshoot this issue as I am not very proficient in terminal and am new to Docker.
When I type docker ps -a
, I get:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f5ed32612a0a ubuntu "bash" 27 minutes ago Exited (129) 22 minutes ago happy_tesla
b179c651b8d7 hello-world "/hello" 40 minutes ago Exited (0) 40 minutes ago mystifying_rubin
c5a91ef51a52 docker101tutorial "/docker-entrypoint.…" 42 minutes ago Created docker-tutorial
916e57976203 hello-world "/hello" 48 minutes ago Exited (0) 48 minutes ago exciting_dewdney
You have to remove (or rename) that container to be able to reuse that name. See 'docker run --help'.
Restart the Docker daemon. On Linux, you can avoid a restart (and avoid any downtime for your containers) by reloading the Docker daemon. If you use systemd , then use the command systemctl reload docker . Otherwise, send a SIGHUP signal to the dockerd process.
To make it short, the reason why this is happening to you is because, when you name containers (with the flag --name foo
), then you have to make sure this name is unique among all the containers you have on your host.
Then regarding your statement:
Can you advise on this error - it seems that I would need to delete a prior container? But I don't believe I created one
If I read your docker ps -a
output, this is untrue, you created one 42 minutes ago, see the really last bit of the below line? This is the name of an existing container, docker-tutorial
:
c5a91ef51a52 docker101tutorial "/docker-entrypoint.…" 42 minutes ago Created docker-tutorial
Just run:
docker rm docker-tutorial
Then you should be able to go back your tutorial.
For the sake of completeness, since it can be unexpected at first usage, the command docker rm
will output back the name of the container that it just deleted:
$ docker rm I-do-exist
I-do-exist
And if you do not have such a named container, then it will output a clear error:
$ docker rm I-do-not-exist
Error: No such container: I-do-not-exist
The command being docker run
and not run
, I suspect there might be some typo, maybe a non-printable character.
Try to type the complete command from a fresh prompt.
Please post the command you are running again removing the backslash
Please post output docker ps -a
it will show you what containers are there running/stopped
You can solve your problem with just two commands
In your terminal type:
docker ps -qa
to find the name that you called your docker container and check the its status says 'exited'(i.e. Container called 'Zen-wu')
docker rm 828a52b426f2
optional
If you want to remove All the exited docker containers do the following command
docker rm $(docker ps -qa)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With