Kinds of Docker “cache”
On a Docker host, reclaimable space usually comes from build cache (BuildKit layers and metadata), unused images, stopped containers, and dangling networks. Named volumes hold database and app data—they are not part of build cache and are easy to destroy accidentally with overly broad prune flags.
Build cache first
docker builder prune drops BuildKit cache entries. Add -a to remove unused build cache not just dangling intermediates. In CI, schedule prunes between jobs or cap cache exporters so runners do not fill disks.
| Command | Effect | Caution |
|---|---|---|
docker builder prune | Remove build cache | Next builds re-pull layers |
docker image prune | Dangling images | Tagged but unused images remain |
docker system prune -a | Aggressive unused removal | Can remove images still needed offline |
Registry is separate
Deleting local images does not delete blobs in a remote registry—run your registry’s garbage-collect workflow after untagging manifests. Coordinate with retention policies so pulls do not break air-gapped mirrors.
Related: Clear nginx cache (for containerized proxies), Clear Redis cache, Linux disk usage commands.