Skip to content
Latchkey

What Is Docker Layer Caching?

Layer caching is the container-build optimization where each instruction in a Dockerfile produces a cacheable layer, and a layer is rebuilt only if it or anything before it changed. Unchanged layers are reused from cache, so editing application code does not force re-installing all dependencies. Ordering the Dockerfile so stable steps come first maximizes cache hits.

Why it matters

Without layer caching, every image build reinstalls all dependencies from scratch, which is slow and wasteful. On ephemeral CI runners the local layer cache vanishes, so teams use a remote layer cache (or registry-backed cache) so fresh runners still benefit. Managed runner platforms often provide this caching.

Related concepts

  • Order Dockerfile steps stable-to-volatile for cache hits
  • Ephemeral runners need a remote layer cache
  • The container analog of a build cache

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →