Docker Image Size Calculator
Estimate the final size of a Docker image from its base image, layer count and average layer size, accounting for multi-stage build savings.
Inputs
Size of the base image, e.g. node:20-slim ≈ 120MB, alpine ≈ 5MB.
Number of RUN/COPY/ADD instructions that add layers.
Average size added per layer (dependencies, build artifacts, etc.).
If enabled, intermediate build-stage layers are discarded from the final image.
Percent of total layer weight that belongs to intermediate build stages (compilers, dev deps) and is discarded with multi-stage builds.
Estimated Final Image Size
320MB
Multi-Stage Savings
0MB
Savings vs Single-Stage
0.0%
Retained Layer Weight
200MB
Step by step
Total layer weight
8 × 25MB
= 200MB
Removed by multi-stage build
not enabled
= 0MB
Final image size
120MB + 200MB
= 320MB
How it works
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
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.
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