Skip to content

The cache

The rule, exactly

The cache key is three things. Hold them and you can predict every rebuild you will ever sit through.

Three things

An instruction is served from cache when a previous build produced an image from the same parent, with the same instruction, over the same sources. That is the whole rule:

The parent image id. The instruction text, after variables are expanded. And, for COPY and ADD only, a checksum of the files being copied.

Nothing about the result is in there. A RUN that produces byte-identical output still misses if its text changed; a RUN curl that would fetch something new still hits if its text did not. The cache is keyed on the recipe, never on the dish — which is also why a cached RUN curl quietly serves you last week's download.

The parent being in the key is what makes the cascade: one miss and everything above it misses too, however unchanged its own text is.

Dockerfile

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

Layers

Nothing has been built yet. Press Build and the layers, the digest and the cache ledger appear — not before.

Everything you do here stays in this browser.Part of liter8.sh