# docker rm Command Reference

> Reference for docker rm in CI: remove one or more containers with -f and -v to force-stop and clean up volumes between pipeline jobs.

Source: https://latchkey.dev/learn/command-reference/docker-rm-command-reference  
Updated: 2026-06-26

Remove one or more containers.

docker rm deletes stopped containers. With -f it stops and removes a running container in one step. In CI it cleans up leftover containers between jobs on a persistent runner; prefer docker run --rm so containers self-clean.

## Common flags

- `-f, --force` - force-remove a running container (SIGKILL then remove)
- `-v, --volumes` - also remove anonymous volumes attached to the container
- `-l, --link` - remove the specified link rather than the container

## Example

```shell
docker rm -f app-web app-db
docker rm -f $(docker ps -aq) 2>/dev/null || true
```

## In CI

On persistent runners, force-remove leftover containers at the start of a job so a stale name does not conflict with a new one ("Conflict. The container name is already in use"). Add || true so an empty list does not fail the step. -v also frees anonymous volumes.

## FAQ

### docker rm Command Reference?

docker rm deletes stopped containers. With -f it stops and removes a running container in one step. In CI it cleans up leftover containers between jobs on a persistent runner; prefer docker run --rm so containers self-clean.

### In CI?

On persistent runners, force-remove leftover containers at the start of a job so a stale name does not conflict with a new one ("Conflict. The container name is already in use"). Add || true so an empty list does not fail the step. -v also frees anonymous volumes.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
