๐ณ No Space Left โ Delete Your Volumes
Docker throwing no space left on device makes it tempting to start deleting things fast — but the actual culprit is almost always accumulated build cache, dangling images, and stopped containers, none of which hold data you need.
๐ Find What’s Actually Eating Space First
docker system df -v # Shows a breakdown: Images, Containers, Local Volumes, Build Cache # - usually "Build Cache" and dangling "<none>" images are the # biggest, most disposable offenders, often for many GB.
โ Safe Cleanup, Broadest to Narrowest
- Start with the safest command and check if it freed enough space before reaching for anything broader.
- None of the commands below touch named volumes by default — that’s the deliberate safety boundary.
๐งน Cleanup Commands, Safest First
# Removes stopped containers, dangling images, unused networks, # and build cache - does NOT touch volumes or running containers docker system prune # Also removes images not currently used by ANY container # (not just dangling ones) - more aggressive but still volume-safe docker system prune -a # Only if you're SURE: also removes unused volumes. # This DOES delete data if a volume isn't attached to a container # right now - check "docker volume ls" and inspect first. docker system prune -a --volumes
โ ๏ธ Before You Add –volumes
- Run ‘docker volume ls’ and cross-check each one against ‘docker ps -a’ — a volume for a container you stopped last week but plan to restart is NOT safe to delete.
- Named volumes for databases (Postgres, MySQL, etc.) hold your actual data — deleting them is equivalent to dropping the database.
docker system df tells you exactly where the space went before you delete anything — skip that step and “cleaning up” becomes indistinguishable from “deleting data.”
