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
docker stop
Gracefully stops one or more running containers by sending SIGTERM and then SIGKILL after a timeout. Use docker kill for an immediate SIGKILL.
docker ps
Lists containers along with their status, ports, and identifiers. By default it shows only running containers unless -a is passed.
docker rmi
Removes one or more images from the local image store. Alias for docker image rm.
docker volume
Manages persistent named volumes for containers — create, list, inspect, remove, and prune. Named volumes survive container removal and are the recommended storage mechanism over bind mounts for stateful data.
docker run
Creates and starts a new container from a specified image in a single step. This is the primary command for launching workloads and supports extensive configuration for networking, storage, and process control.
← All Docker commands · Docker vs Kubernetes · Docker vs VMs