containers

docker rm

Removes one or more stopped containers from the host. Use -f to force-remove a running container.

docker rm [OPTIONS] CONTAINER [CONTAINER...]

Common flags

Flag Purpose
-f, --force Force removal of a running container (sends SIGKILL)
-v, --volumes Also remove anonymous volumes associated with the container
-l, --link Remove the specified legacy link, not the container

Examples

docker rm web

Delete a stopped container by name

docker rm -fv old-api

Force-remove running container along with anonymous volumes

docker rm $(docker ps -aq --filter status=exited)

Clean up all exited containers

docker container prune

Interactive bulk cleanup alternative

Gotcha

Named volumes are NEVER removed by -v — only anonymous volumes are. Forgetting -v leaves orphan anonymous volumes that consume disk over time; run docker volume prune to clear them.

Related commands

← All Docker commands · Docker vs Kubernetes · Docker vs VMs