Quick fix
# One shot: remove the name holder (works even when exited), then rerun
docker rm -f repro-conflict && docker run -d --name repro-conflict alpine sleep 60
What you will run into
Running docker run --name xxx ... a second time with the same name fails with docker: Error response from daemon: Conflict. The container name "/xxx" is already in use by container "...".
Most common in script re-runs, CI retries and tutorial walkthroughs — container names are globally unique per daemon: docker stop does not free the name, and plain docker ps (without -a) does not show the exited container, so it is easy to misread the name as free.
Why this happens
--name registers the name in the daemon's global name index at container create time. docker stop only moves the container to the exited state — the container object and its name still exist; only docker rm deletes the object and releases the name.
So "run the same command twice" collides. Compose does not hit this because it removes old containers before recreating them.
The container lifecycle is create → start → stop → rm: the name is claimed at create and released only at rm; stop does not release it.
The by container "<id>" part of the error identifies the current name holder — docker ps -a will always show it, because plain docker ps only lists running containers.
Deterministic takeaway: either docker rm -f the holder or use a different --name — there is no third option; "remove then create" is the idempotent standard for site docs
Step by step
1. Find the name holder — Must do
docker ps -a | grep <name>
Exited containers are hidden from plain docker ps; you need -a.
2. Remove it if it is useless — Must do
docker rm -f <name> # running container: -f force; exited: plain rm is enough
3. Rename instead (keep the old container) — By scenario
docker rename <old> <new> # or start the new one with a different --name
How to confirm it works
docker ps -a | grep <name> shows no same-name container; rerunning docker run --name <name> succeeds and prints a container id with no Conflict error.
Other environments
| Environment | Note |
|---|---|
| Exited container holds the name | Only visible with docker ps -a (reproduced: stop keeps the name) |
| Running container holds the name | docker rm -f, or stop then rm |
| Compose | Normally handled; if you see it, a hand-run container with the same name exists |
Symptom
docker: Error response from daemon: Conflict. The container name "/repro-conflict" is already in use by container "49e3c7e4...". You have to remove (or rename) that container to be able to reuse that name.
Run 'docker run --help' for more information
Signature: the second docker run --name with the same name fails; the error carries the full Conflict. The container name "..." is already in use text and the holder container id.
Cause
Container names are a daemon-global unique resource, claimed at create and released only at rm; stop does not release it. Creating the same name again is a Conflict; docker ps only lists running containers, so "not visible" is easily misread as "name free".
Solution
docker ps -a | grep <name>to find the holder;- Useless →
docker rm -f <name>; useful →docker renameor pick another name; - In site docs remove before create (
docker rm -ffirst) or add|| truefor idempotency.
Verification Evidence
- Local reproduction (2026-08-31, WSL Ubuntu, docker 29.1.3, alpine:latest):
- Chain A:
docker run -d --name repro-conflict alpine sleep 60succeeds (prints container id) → same command again →docker: Error response from daemon: Conflict. The container name "/repro-conflict" is already in use by container "49e3c7e4..."(exit 125); - Chain B:
docker rm -f repro-conflictthen the same command → succeeds.
Evidence details kept locally (2026-08-31)
Related canonicals
Read in order: precondition -> same root / same domain / related:
- Related (similar errors, different cause):
- Docker daemon unreachable (confirm the daemon is alive before hunting name conflicts)
Applicable tools (1)
This problem is linked from the tool pages below — reachable from either side.
dockerSource & evidence
← Coding Agents & Terminal domain | Problem Catalog Experience | Facing another issue? Go to the Helpdesk