docker rm: Remove Containers & Force Cleanup
Delete containers - stopped by default, running ones with -f.
docker rm (alias docker container rm) removes containers. This page covers force removal, removing anonymous volumes, and bulk cleanup in CI.
What it does
docker rm deletes one or more stopped containers and their writable layer. With -f it stops (SIGKILL) and removes a running container in one step.
Common usage
docker rm web
docker rm -f web # force-remove a running container
docker rm -v web # also remove anonymous volumes
docker rm $(docker ps -aq) # remove all containersCommon errors in CI
"You cannot remove a running container ... Stop the container before attempting removal or force remove" - add -f, or stop it first. "docker rm requires at least 1 argument" happens when docker ps -aq is empty; guard the cleanup step. Prefer running disposable containers with --rm so CI does not accumulate stopped containers at all.