Skip to content
ENExplore Calculators

Docker Build Cache Calculator

Quantify build time saved by Docker layer caching and layer ordering.

About Docker Build Cache Calculator

Docker invalidates every layer after the first change, so a modification near the top rebuilds almost everything. Putting dependency installation before source copying is what keeps the expensive layers cached. Copying source before installing dependencies is the single most common Dockerfile mistake and usually multiplies CI build time several times over.

Formula

Docker Build Cache

Layers rebuilt = total layers − first changed layer + 1; everything after a change is invalidated

cache invalidation
A changed layer invalidates itself and every layer after it
layer ordering
Stable steps such as dependency installation belong early

Worked example

With the default values below, Docker Build Cache Calculator returns Build Time With Cache of 151.3. Change any input above and every figure here is recalculated in your browser.

Inputs used

Layers in the Dockerfileminimum 1
12
First layer that changesminimum 1
8
Average layer build timeminimum 0 s
25 s
Builds per dayminimum 0
30
Cache availabilityaccepts 0–100 %
85 %

Results

Build Time With Cache
151.3 s
Build Time Without Cache
300.0 s
Layers Rebuilt
5
Daily Build Time Saved
74.38 min
Recommendation
Layer ordering and cache availability are both working well

Step by step

  1. 1Values used
  2. 2Docker Build Cache
  3. 3Build Time With Cache= 151.3 s
  4. 4Build Time Without Cache= 300.0 s
  5. 5Layers Rebuilt= 5
  6. 6Daily Build Time Saved= 74.38 min
  7. 7Recommendation= Layer ordering and cache availability are both working well

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 2 decimal places, 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

How is Docker Build Cache calculated?

Layers rebuilt = total layers − first changed layer + 1; everything after a change is invalidated Docker invalidates every layer after the first change, so a modification near the top rebuilds almost everything. Putting dependency installation before source copying is what keeps the expensive layers cached.

Why does Docker Build Cache matter?

Copying source before installing dependencies is the single most common Dockerfile mistake and usually multiplies CI build time several times over.

What values do I need to enter?

This calculator takes 5 inputs: Layers in the Dockerfile, First layer that changes, Average layer build time, Builds per day, Cache availability. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.

Docker Build Cache Calculator | Calcrivo