Skip to main content

How does Docker detect and garbage-collect orphaned build layers?

Senior Docker
Quick Answer Build layers that are no longer referenced by any image tag become dangling. Docker's garbage collector (triggered by docker image prune or BuildKit's own GC) identifies layers with no referencing manifests and removes them. BuildKit tracks layer dependencies more precisely than the classic builder and GC's more aggressively.

Answer

Unreferenced layers become dangling and are removed by docker system prune.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice