Skip to content
LatchkeyLatchkey home

docker rm Command Reference

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.

Key takeaways

  • -f stops and removes a running container in one step.
  • -v also removes anonymous volumes the container created.
  • Prefer docker run --rm so most containers never need manual rm.

Frequently asked questions

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.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card