Docker Image Size Calculator
Estimate the final size of a Docker image from its base image and added layers.
About Docker Image Size Calculator
A Docker image's final size is the base image plus every unique layer added by RUN, COPY and ADD instructions. Multi-stage builds let you compile or build in one stage (pulling in compilers and dev dependencies) and copy only the final artifacts into a clean final stage, discarding everything else. This calculator estimates the final size both with and without that optimization by applying the fraction of layer weight assumed to be intermediate-only.
Formula
finalSize = baseImage + (layers × avgLayerSize) × (1 - multiStage × intermediateFraction)
- B
- Base image size in MB
- N
- Number of layers
- L
- Average layer size in MB
- m
- Multi-stage enabled (0 or 1)
- f
- Intermediate layer fraction removed
- S
- Final image size in MB
Worked example
With the default values below, Docker Image Size Calculator returns Estimated Final Image Size of 320. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Base Image Sizeaccepts 0–20,000 MB
- 120 MB
- Number of Layersaccepts 0–200 layers
- 8 layers
- Average Layer Sizeaccepts 0–5,000 MB
- 25 MB
- Multi-Stage Build
- No
- Intermediate Layers Removedaccepts 0–100 %
- 60 %
Results
- Estimated Final Image Size
- 320 MB
- Multi-Stage Savings
- 0 MB
- Savings vs Single-Stage
- 0.0%
- Retained Layer Weight
- 200 MB
Step by step
- 1Total layer weight= 200MB
- 2Removed by multi-stage build= 0MB
- 3Final image size= 320MB
Assumptions and limits
- The result is derived only from the 5 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
Why does my image stay large even after deleting files in a later layer?
Docker's union filesystem is layer-based and additive — deleting a file in a later layer just adds a 'tombstone' marker; the original bytes remain in the earlier layer and still count toward image size. Multi-stage builds avoid this by never including those layers in the final image.
What's a realistic intermediate layer fraction?
For compiled languages (Go, Rust, Java) it's common for 70-90% of build-stage weight (compilers, SDKs, caches) to be discardable. For interpreted languages with many dev dependencies, 40-60% is typical.
Does choosing a smaller base image matter more than multi-stage builds?
Both matter — base image choice (e.g. alpine vs. full Debian) sets your floor, while multi-stage builds control how much of your build toolchain leaks into the shipped image.
How can I verify the actual size?
Run `docker images` or `docker image inspect` after building, and use `docker history <image>` to see the size contribution of each layer.
Related Calculators
You might also need
- Docker Build Time EstimatorCommonly used together
- Docker Container Memory CalculatorCommonly used together
- Docker Registry Storage CalculatorCommonly used together
- Docker Multi-stage Build Savings CalculatorCommonly used together
- Docker Pull Time CalculatorCommonly used together
- Docker Layer Size CalculatorCommonly used together
