# Conflict. The container name "/x" is already in use by container …

**Code:** `Conflict container name` · **Category:** Docker · **Seen on:** Docker

A container (running or stopped) already has that name; Docker won’t create a second one with the same name.

## Meaning

Stopped containers keep their names until removed. Scripts that use `docker run --name x` fail on the second run unless they remove the old container first.

## Common causes

- Old stopped container with the same name
- Script/CI re-running `docker run --name` without cleanup
- Compose project renamed, leaving old containers

## Quick fix

1. Remove it: `docker rm -f x`
2. Use `docker run --rm` for one-off containers
3. Use Compose, which replaces containers on `up`

## Detailed fix by platform

### Docker

1. Idempotent run in scripts:

```bash
docker rm -f api 2>/dev/null || true
docker run -d --name api -p 8080:8080 ghcr.io/acme/api:latest
```


## How to diagnose

1. **Existing** — `docker ps -a --filter name=x`
2. **Script** — Does it clean up before run?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/docker/container-name-already-in-use)
