4

[SOLVED] The Container Name Is Already In Use By Container

 1 year ago
source link: https://www.shellhacks.com/the-container-name-is-already-in-use-by-container/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

[SOLVED] The Container Name Is Already In Use By Container

While starting a Docker container, you may sometimes receive “the container name is already in use by container” error.

The complete error looks like as follows:

ERROR: for <containerName> Cannot create container for service <serviceName>: Conflict. The container name “<containerName>” is already in use by container “<containerID>”. You have to remove (or rename) that container to be able to reuse that name.

This short note shows how to fix “the container name is already in use by container” error.

Cool Tip: Remove all Docker images and containers! Read More →

The Container Name Is Already In Use By Container

The error “the container name is already in use by container” means that the container with the same name already exists.

If you don’t see it among the running containers with a docker ps command, it is probably be in the Exited state.

To list all the containers, execute:

$ docker ps -a
- sample output -
CONTAINER ID  IMAGE  COMMAND  CREATED     STATUS                 PORTS   NAMES
df51f67134f2  nginx  "/d..."  5 mins ago  Exited (1) 2 mins ago  80/tcp  nginx

To fix the “the container name is already in use by container” error you can either rename your container or, if you are sure that the old container is not needed anymore, you can simply delete the old one.

To delete the container, run one of the commands below:

$ docker rm <containerName>
- or -
$ docker rm <containerID>

Once the conflicting container is deleted, “the container name is already in use by container” error should not be thrown anymore.

Cool Tip: How to start a Docker container! Read More →


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK