Skip to content
Calcrivo

Docker Layer Size Calculator

Break down how much each Dockerfile instruction adds to your final image layers.

Inputs

MB

Size of the FROM base image.

layers

RUN/COPY/ADD instructions that produce new layers.

MB

Average size of each added layer.

MB

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

  1. Added layers total

    8 × 15MB

    = 120.0MB

  2. Total image size

    80MB + 120.0MB

    = 200.0MB

  3. 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