Docker eating your disk? builder prune, system df and the vhdx trap

Diagnose first

docker system df          # images/containers/volumes/build-cache totals
docker system df -v       # detail

Safe pruning order

docker builder prune                 # build cache — biggest & safest win
docker image prune                   # dangling images
docker container prune
docker volume prune                  # ⚠ only if no named volumes you need
docker system prune                  # the above, combined
Don't run docker system prune -a --volumes blindly: -a removes all unused images (slow re-pulls) and volumes may hold your databases.

The sparse-file trap

Docker Desktop's Docker.raw (macOS) / DockerDesktop.vhdx (Windows) grows but never shrinks after pruning. Reclaim: Docker Desktop → Settings → Resources → "Clean / Purge data", or compact the vhdx (Optimize-VHD / diskpart).

FAQ

Will prune delete my containers' data?
Running containers and their writable layers are untouched by default prune; named volumes need --volumes flag to be touched.