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.
More on Images, Layers & Storage Drivers
What is a Docker image made of?BeginnerWhat is a layer and when is one created?BeginnerWhat is a union filesystem / OverlayFS?IntermediateWhat is copy-on-write (CoW) in containers?IntermediateWhy does deleting a file in a later `RUN` not shrink the image?IntermediateWhat storage drivers does Docker support and which is default?Intermediate