Skip to content
ENExplore Calculators

Docker Multi-stage Build Savings Calculator

Compare final image size before and after adopting multi-stage Docker builds.

About Docker Multi-stage Build Savings Calculator

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.

Formulas

Multi-stage final image size

final_size = base_runtime_image + runtime_deps

base_runtime_image
Size of the minimal runtime base image (MB)
runtime_deps
Size of runtime-only dependencies (MB)

Image size savings

savings_percent = (single_stage_size - final_size) / single_stage_size × 100

single_stage_size
Single-stage image size (MB)
final_size
Multi-stage final image size (MB)

Worked example

With the default values below, Docker Multi-stage Build Savings Calculator returns Image Size Savings of 800. Change any input above and every figure here is recalculated in your browser.

Inputs used

Single-Stage Image Sizeaccepts 0–50,000 MB
950 MB
Builder-Only Dependenciesaccepts 0–50,000 MB
480 MB
Runtime Dependenciesaccepts 0–50,000 MB
90 MB
Base Runtime Imageaccepts 0–20,000 MB
60 MB

Results

Image Size Savings
800 MB
Savings vs Single-Stage
84.2%
Multi-Stage Final Image Size
150 MB
Builder Weight Discarded
480 MB

Step by step

  1. 1Multi-stage final size: base + runtime deps= 150MB
  2. 2Savings: single-stage − multi-stage final= 800MB
  3. 3Savings %: savings / single-stage × 100= 84.2%
  4. 4Builder-only weight discarded= 480MB

Assumptions and limits

  • The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 1 decimal place, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

What typically counts as a 'builder-only' dependency?

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.

Can I have more than two stages?

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.

Does multi-stage affect build time as well as image size?

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.

Why is a smaller final image good beyond disk space?

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.

Docker Multi-stage Build Savings Calculator | Calcrivo