ipdetecto.com logo
ipdetecto.com
My IPSpeed
Knowledge Hub
HomeKnowledge HubClear Docker Cache
© 2026 ipdetecto.com
support@ipdetecto.comAboutContactPrivacyTermsllms.txt
Network Administration
5 MIN READ
Apr 19, 2026

How to Clear Docker Cache

Clear BuildKit build cache, dangling images, and unused layers with docker builder prune and controlled system prune—without deleting named volumes or remote registry blobs you still need.

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.

CommandEffectCaution
docker builder pruneRemove build cacheNext builds re-pull layers
docker image pruneDangling imagesTagged but unused images remain
docker system prune -aAggressive unused removalCan 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.

Frequently Asked Questions

Q.Does docker system prune delete volumes by default?

No—volumes are kept unless you pass --volumes, which can wipe databases. Always read the confirmation prompt and protect named volumes in compose files.

Q.What is the difference between docker builder prune and docker image prune?

builder prune targets BuildKit layer cache used for faster docker build. image prune removes unused images (often dangling layers) but not necessarily all build cache metadata.

Q.Will pruning break running containers?

Running containers keep their writable layers; pruning removes unused images and build cache that nothing references—still verify with docker ps and compose stacks before -a.

Q.Why did CI get slower after prune?

Cold cache means rebuilds must recompute layers and re-download bases—expected tradeoff; tune cache exporters or retain a warmed runner pool.

Q.How do I see disk usage before pruning?

Use docker system df for a summary; pair with host df -h and du on /var/lib/docker when you need filesystem-level detail.

Q.Does pruning remove images from a remote registry?

No—only local engine storage. Remote blobs remain until registry garbage collection removes unreferenced manifests and layers.

Q.Is BuildKit the default builder?

On modern Docker Desktop and recent engine installs, yes—DOCKER_BUILDKIT=1 behavior is common; legacy builder cache paths differ slightly.

Q.Can I prune on Kubernetes nodes safely?

Only with ops discipline—node pressure eviction differs from docker prune; coordinate with image GC settings on kubelet and avoid pruning images still needed by pending pods.
TOPICS & TAGS
docker builder prunedocker system pruneBuildKit cacheclear docker build cachedocker image pruneregistry garbage collection