Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker says there is already a container with the same name that exists despite there are no containers

I do DOCKERADM_ENV=lab docker-compose -f docker-compose-mgmt.yml up -d since last week to test things and when I want to test something new I remove all the containers with docker rm $(docker ps -aq).

But now I can't make my docker-compose because :

ERROR: for mgmt-mongo Conflict. The name "/mgmt-mongo" is already in use by container 228f13fb40231043d3c532cc1fa40906eb4332722a6a69024fe6b9d0ceab8b40. You have to remove (or rename) that container to be able to reuse that name.

But when I do docker ps -a there is nothing.

You have an idea from where it could comes ?

like image 907
Jerome Avatar asked Mar 13 '17 11:03

Jerome


People also ask

Can two docker containers have the same name?

Note: Container names must be unique. That means you can only call one container web . If you want to re-use a container name you must delete the old container (with docker container rm ) before you can create a new container with the same name. As an alternative you can use the --rm flag with the docker run command.

How do I rename an existing container?

To rename a docker container, use the rename sub-command as shown, in the following example, we renaming the container discourse_app to a new name disc_app. After renaming a containers, confirm that it is now using the new name. For more information, see the docker-run man page. That's all!

Can one docker image have multiple containers?

With Docker compose, you can configure and start multiple containers with a single yaml file. This is really helpful if you are working on a technology stack with multiple technologies.


1 Answers

run this:

docker rm 228f13fb40231043d3c532cc1fa40906eb4332722a6a69024fe6b9d0ceab8b40

sounds like you have a an orphaned container or something like that... but Docker was kind enough to give you the id of the container, so you can just remove that container by its id.

like image 156
Derick Bailey Avatar answered Nov 02 '22 02:11

Derick Bailey