Skip to content
BENIBIX Learn

Image Layer

Infrastructure📦 ContainersImage Builds

Also known as Docker Layer, Container Image Layer, Layer Cache

One saved set of file changes. Layers stack up to make a container image.

Think of it like

Think of it like a stack of see-through sheets. Each sheet adds a little to the picture.

Example

Jack's build installs packages, then copies in his code. He changes one file. The rebuild reuses the package layer and only redoes the last one.

Why it matters

Layers make builds and downloads fast, because only changed layers are redone. The order of steps decides how much is reused.

Definition

An image layer is one saved set of file changes inside a container image. Build steps that change files each add a layer, such as installing a package or copying in code. The layers stack up to make the whole image. Once made, they never change. Images that start the same way share those layers, so they are stored and downloaded once. A running container adds one thin layer on top where it can write.
Each solid band is a layer that never changes. Only the thin top layer of a running container can be written.

Common mistake

Copying all the code before installing packages. Then any code change redoes the slow install step too.

Key takeaways

  1. 1
    Stacked changes. Each layer adds or changes files.
  2. 2
    Never changed. A finished layer stays as it is.
  3. 3
    Shared and cached. The same layer is reused, not redone.