The container name "/..." is already in use
The container name "/..." is already in use
DodaTech
2 min read
The “container name is already in use” error occurs when you try to create a container with a name that is already assigned to an existing container. Every container name must be unique on a single Docker host.
What It Means
Docker requires unique container names within the same Docker host. When you run docker run --name my-app ... and my-app already exists (running or stopped), Docker refuses to create the new container.
Why It Happens
- You ran the same
docker runcommand twice without removing the first container. - A previous container with that name exists in the “exited” state.
- You are re-creating a container during development without cleaning up old ones.
- A CI/CD pipeline or script does not remove containers between runs.
How to Fix It
1. Remove the existing container
docker rm <container-name>Force removal if the container is still running:
docker rm -f <container-name>2. Verify the container is gone
docker ps -a | grep <container-name>No output means the container was successfully removed.
3. Re-run with the container name
docker run --name my-container -d nginx4. Use a different name
docker run --name my-container-v2 -d nginx5. Use the --rm flag for ephemeral containers
The --rm flag automatically removes the container when it stops, preventing stale name conflicts:
docker run --rm --name my-container nginx6. List all existing container names to check
docker ps -a --format "table {{.Names}}\t{{.Status}}"FAQs
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro