docker container prune: Remove Stopped Containers
Remove every stopped container in one command.
docker container prune deletes all stopped containers at once. This page covers the filter flags and using it for CI cleanup.
What it does
docker container prune removes all containers in the exited/created state. It is the bulk equivalent of docker rm on each stopped container.
Common usage
Terminal
docker container prune -f
docker container prune -f --filter "until=1h"Common errors in CI
Without -f it prompts and stalls non-interactive CI - pass -f. It only removes stopped containers, so a still-running one survives; stop it first if you need a clean slate. Running disposable containers with --rm avoids the need for this entirely.
Related guides
docker rm: Remove Containers & Force CleanupHow docker rm works: removing stopped containers, force-removing running ones, removing volumes, and CI clean…
docker system prune: Reclaim Disk in CIHow docker system prune works: removing stopped containers, unused networks, dangling images, and build cache…
docker ps: List Containers, Filters & FormattingHow docker ps works: listing running and stopped containers, filters, format strings, and reading exit status…
docker stop: Gracefully Stop ContainersHow docker stop works: sending SIGTERM then SIGKILL, the grace period, stopping multiple containers, and clea…