Docker Disk Space Cleanup
Docker Disk Space Cleanup (Hosts)
Docker data grows over time on host machines. Old rentals leave behind stopped containers, unused images, volumes, and build cache. If you don’t clean it up, the root disk fills up and deployments start failing.
1) Check disk usage
OS-level disk space (df -h)
This shows free space on each mounted filesystem.
df -hYou care mainly about / (root) and the partition that holds /var/lib/docker.
Docker-level disk usage (docker system df)
This shows what Docker is storing and how much is reclaimable.
docker system dfIf you want more detail per image/container:
docker system df -v2) Complete cleanup (recommended)
This is the “reset Docker leftovers from previous rentals” command. It removes unused containers, images, networks, and unused volumes.
3) Individual cleanup commands (more control)
Use these when you want to clean a specific category. They’re safer for incremental maintenance.
Containers (stopped only)
Images (unused)
Remove dangling layers only:
Remove all unused images (same risk as system prune -a):
Volumes (unused)
Networks (unused)
4) Best practices for host maintenance
Clean up between rentals or during planned downtime.
Keep a safety buffer. Aim for 10–20 GB free on the root disk at all times.
Check Docker usage regularly:
df -hdocker system df
Prefer incremental cleanup first:
docker container prunedocker image prunedocker volume prune
Use full cleanup only when needed:
docker system prune -a --volumes
If disk usage keeps growing fast, investigate:
Large volumes created by renters.
Logs under
/var/lib/docker/containers/*/*.log.Build cache from frequent image rebuilds.
Last updated
Was this helpful?