Compare final image size before and after adopting multi-stage Docker builds.
A single-stage Dockerfile ships the base image plus every dependency used at any point in the build, including compilers and dev tooling never needed at runtime. A multi-stage build compiles in a throwaway 'builder' stage and copies only the finished artifacts into a minimal final stage. Formula: savings = single_stage_size − (base_runtime_image + runtime_deps); savings% = savings / single_stage_size × 100. The builder-only dependency weight is exactly what gets discarded.
Multi-stage final image size
final_size = base_runtime_image + runtime_deps
Image size savings
savings_percent = (single_stage_size - final_size) / single_stage_size × 100
Compilers (gcc, tsc), SDKs, build caches, dev/test dependencies, and source files not needed at runtime — anything that exists solely to produce the final binary or bundle.
Yes — Dockerfiles support any number of named stages (FROM ... AS name), and you can copy artifacts from any earlier stage with COPY --from=name. Two stages (builder + runtime) is the most common pattern.
Build time is largely unchanged (you still run the same build steps) but layer caching per-stage can speed up incremental builds; the primary win is the smaller shipped artifact, faster pulls, and reduced attack surface.
Smaller images pull faster (faster deploys and autoscaling), have a smaller attack surface for vulnerability scanners to flag, and reduce registry storage/egress costs at scale.