Docker storage guide

Reduce Docker disk usage without treating every object alike.

Images, stopped containers, build cache, and volumes have different consequences. Inspect reclaimable space by object type before you use a broad prune command.

ImagesMay be downloaded or rebuilt again, but that costs time and bandwidth.
Build cacheSpeeds future builds and is generally reproducible.
VolumesCan contain databases and other irreplaceable local state.

Start with Docker’s own inventory

Docker manages its data through the engine. Use engine-reported object and reclaimable sizes instead of deleting files inside Docker Desktop’s storage directly. Docker intentionally keeps unused objects until you explicitly ask to remove them.

Know the four major object types

Images

Dangling images are untagged and not referenced by a container. The broader docker image prune -a can remove every image not associated with an existing container, including images you expected to reuse.

Stopped containers

A stopped container can retain a writable layer and configuration. Removing it is different from removing the image it was created from.

Build cache

BuildKit cache can be regenerated by future builds. Removing it may reclaim substantial space, but the next build can become slower and download more data. Multiple builders can maintain separate caches.

Volumes

Volumes are the high-risk category. Docker does not remove them automatically because they may contain persistent application data. “Unused by a current container” does not mean “unimportant.”

Avoid blind commands: docker system prune --volumes expands a general cleanup to unused volumes. Review volume names, labels, projects, backups, and data ownership first.

A safer cleanup order

  1. Stop active development stacks cleanly.
  2. Review engine-reported disk usage and reclaimable size.
  3. Remove clearly obsolete stopped containers.
  4. Review dangling or old unused images.
  5. Prune build cache with a scope or retention target.
  6. Treat every volume as user data until proven otherwise.

SpaceLint uses Docker’s own reported inventory, separates rebuildable objects from data-risk categories, and keeps volumes protected rather than presenting all Docker storage as generic cache.

Official references

See reclaimable Docker storage with its risk attached.

SpaceLint reports engine-known objects and keeps semantically risky data out of automatic cleanup.