Docker Cleanup One-Liners for Disk Space Emergencies
Build hosts fill up. Here's the order I clean things in before reaching for system prune -a with no filters.
See what's actually taking up space
docker system df -v
Remove stopped containers
docker container prune -f
Remove dangling images (safe, untagged layers only)
docker image prune -f
Remove images not used by any container, older than 72h
docker image prune -a --filter "until=72h" -f
Kill unused volumes (check first — this is the destructive one)
docker volume ls -f dangling=true
docker volume prune -f
Clear build cache
docker builder prune -f --filter "until=168h"
Full nuke when you're sure
docker system prune -a --volumes -f
Find the biggest images on a host
docker images --format '{{.Size}}\t{{.Repository}}:{{.Tag}}' | sort -rh | head -20
Run the -v variants first to see the blast radius before anything with -f on a shared runner.