supraj.dev
Containers

Docker layer caching

Why is my second Docker build so much faster than the first one?

28 s loop7 sentencesSilent, read alongScene: Layers
Read the story, sentence by sentence 7 sentences

What you'll be able to say

  1. Each Dockerfile instruction adds a layer to the image, and layers stack on top of the ones before them.
  2. Docker’s build cache reuses a layer when its instruction and copied files are unchanged; a change invalidates that layer and all later ones.
  3. Copy package.json and run npm install before copying your source code, so code edits reuse the cached dependency layer.