Back to Blog

docker cleaning

696a4edf0617153016f9e0d8โ€ข

Perfect โ€” this output tells us exactly where your disk space is stuck ๐Ÿ‘

๐Ÿ” Whatโ€™s going on

  • Images: 36.28 GB total โ†’ 33.66 GB reclaimable (92%)
  • Build cache: 33.96 GB total โ†’ 31.51 GB reclaimable
  • Containers: all active โŒ (donโ€™t touch)
  • Volumes: all in use โŒ (donโ€™t touch)

๐Ÿ‘‰ You can safely free ~65 GB without breaking running containers.


โœ… SAFE cleanup (recommended for your state)

1๏ธโƒฃ Clear Docker build cache (BIGGEST win)

docker builder prune -a -f

๐Ÿงน Frees ~31.5 GB


2๏ธโƒฃ Remove unused images (not used by running containers)

docker image prune -a -f

๐Ÿงน Frees ~33.6 GB

โœ” Running containers will NOT be affected
โœ” Images used by active containers are kept


โŒ DO NOT run these (for now)

docker container prune   # all containers are active
docker volume prune      # all volumes are in use

๐Ÿ“Š Verify space freed

docker system df
df -h

You should see Docker usage drop dramatically.


๐Ÿ›ก๏ธ Extra safety check (optional)

See which images are actually in use:

docker ps --format "table {{.Image}}\t{{.Names}}"

๐Ÿ” Prevent this from happening again

Add a weekly cleanup cron (safe)

crontab -e

Add:

0 3 * * 0 docker builder prune -a -f && docker image prune -a -f

๐Ÿง  Pro tip (important for Tamashani)

Since you deploy often:

  • Use multi-stage Docker builds
  • Avoid latest tags
  • Clean build cache after CI/CD deploys

If you want, paste:

docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"

Iโ€™ll tell you which images are bloated and how to slim them down ๐Ÿš€