Docker Layer Size Calculator
Break down how much each Dockerfile instruction adds to your final image layers.
Inputs
Size of the FROM base image.
RUN/COPY/ADD instructions that produce new layers.
Average size of each added layer.
Size of the single largest layer (e.g. apt-get install).
Total Image Size
200.0MB
Added Layers Total
120.0MB
Largest Layer Share
60.0%
Base Image Share
40.0%
Step by step
Added layers total
8 × 15MB
= 120.0MB
Total image size
80MB + 120.0MB
= 200.0MB
Largest layer share
120MB / 200.0MB
= 60.0%
How it works
Each Dockerfile instruction (RUN, COPY, ADD) creates a new read-only layer in the union filesystem. The total image size equals the base image plus all added layers. Identifying which layers contribute the most size helps optimize the Dockerfile by combining commands, using multi-stage builds, or choosing smaller base images.
Formula
Total Image Size
totalSize = baseImage + (numLayers × avgLayerSize)
- baseImage
- Base image size in MB
- numLayers
- Number of added layers
- avgLayerSize
- Average layer size in MB
Frequently Asked Questions
How can I reduce the number of layers?
Chain multiple RUN commands with && to produce a single layer, and clean up temporary files within the same RUN instruction so deleted content never appears in a layer.
Does layer order affect final image size?
No — total size is the sum of all layers regardless of order. However, ordering affects cache invalidation: placing frequently-changing instructions last maximizes cache hits for earlier layers.
You might also need
- Docker Image Size CalculatorCommonly used together
- Docker Cache Efficiency CalculatorCommonly used together
- Docker Image Compression CalculatorCommonly used together
- Docker Storage Driver Overhead CalculatorCommonly used together
- Docker Multi-stage Build Savings CalculatorCommonly used together
- Docker Build Time EstimatorAlso in Docker