Interview Prep/Docker/Images, Layers & Storage Drivers

What is image squashing and when would you use it?

AdvancedConceptImages, Layers & Storage Drivers
Answer

Squashing merges all layers into one, removing deleted data and reducing size for builds with lots of churn. The cost is losing layer sharing and cache reuse. With BuildKit, a multi-stage final stage that copies / from the previous stage (COPY --from=build / /) achieves the same effect. Generally prefer proper multi-stage builds.

All Docker questions Roadmap: Docker & containers

More on Images, Layers & Storage Drivers