liveBook · Manning

Multi-layer image

As explained in Learn Docker in a Month of Lunches, Second Edition

A multi-layer image distributes its filesystem data across multiple image layers to enable concurrent layer transfer.

A multi-layer image spreads filesystem data across several image layers so Docker Engine can transfer layers concurrently. Splitting large files can improve pulls on new machines and auto-scaling container platforms. section 17.4

Use the approach when transfer speed matters, while accounting for its trade-offs:

  • Copy each large data file into its own layer instead of copying all files through one pattern. section 17.4
  • Expect more brittle Dockerfiles because every file must be listed explicitly. section 17.4
  • Remember that Docker downloads three layers concurrently by default, with the Engine configuration able to change that limit. section 17.4

Compare one layer with many layers

Build both targets with `docker build -t diamol/ch17-ml-dataset:v4-one-layer -f Dockerfile.v4 --target one-layer .` and `docker build -t diamol/ch17-ml-dataset:v4-multi-layer -f Dockerfile.v4 --target multi-layer .`, then inspect them using `docker history`.

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains the transfer rationale, Dockerfile trade-off, concrete targets, and verification commands, but does not detail layer internals.
Examples
Compares ML dataset images that copy days 70–79 in one layer or separate layers, then inspects histories.
What it assumes
Assumes familiarity with Dockerfiles, COPY instructions, build targets, and basic Docker image commands.
What you can do after
Apply it via Docker CLI by building alternative targets, comparing image sizes, and inspecting their layer histories.
How it connects
Connects Dockerfile COPY instructions, multi-stage builds, Docker image layers, and Docker Engine download concurrency.

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.