Skip to content
Calcrivo

Docker Build Time Estimator

Estimate total docker build duration from layer count, cache hits and build steps.

Inputs

layers

Number of build instructions (RUN/COPY/ADD) in the Dockerfile.

seconds

Average time to execute one layer's instruction from a cold cache.

%

Percent of layers expected to be served from build cache.

×

Effective parallelism from multi-stage builds run concurrently or BuildKit parallel stage execution.

Estimated Build Time

120.0seconds

Estimated Build Time

2.00minutes

Uncached Layers

6layers

Cached Layers

4layers

Time Saved by Cache

80.0seconds

Step by step

  1. Uncached fraction: 1 − cache hit rate

    1 − 40/100

    = 0.60

  2. Sequential build time

    10 × 20s × 0.60

    = 120.0s

  3. Build time with parallelism

    120.0s ÷ 1

    = 120.0s

How it works

Docker build time is driven by how many layers must actually execute versus how many are served from cache: time = layers × avg_layer_time × (1 − cache_hit_rate) ÷ parallel_factor. Ordering Dockerfile instructions so that frequently-changing steps (e.g. COPY source code) come after stable steps (e.g. installing dependencies) maximizes cache hit rate on incremental builds.

Formula

buildTime = (layers × avgLayerTime × (1 - cacheHitRate)) / parallelFactor

N
Number of layers
t_l
Average layer build time in seconds
h
Cache hit rate (0 to 1)
P
Parallel build factor
T
Estimated build time in seconds

Frequently Asked Questions

How do I improve my cache hit rate?

Order Dockerfile instructions from least to most frequently changing, copy dependency manifests (package.json, requirements.txt) before application source code, and use BuildKit's cache mounts for package manager caches.

What does the parallel build factor represent?

It models BuildKit's ability to build independent multi-stage build stages concurrently, or running multiple image builds concurrently in CI. A factor of 1 means fully sequential.

Why is a full cache miss so much slower?

Every layer must re-download dependencies, recompile, and re-execute from scratch — this is the classic 'cold cache' first build a CI runner experiences after cache eviction.

Does using a remote build cache help in CI?

Yes — CI runners often start with cold local caches; pulling a remote cache (registry cache or BuildKit --cache-from) before building restores a meaningful cache hit rate on ephemeral runners.

You might also need