liveBook · Manning

Multi-platform Dockerfile

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

A Dockerfile intended to build compatible image variants for multiple target platforms.

A multi-platform Dockerfile builds image variants for different target architectures from one definition. Base the image on a multi-platform image and restrict commands to operations supported by every target. section 12.2

Use this pattern carefully:

  • Avoid platform-specific commands such as chmod when they may not work on every architecture. section 12.2
  • Remember that RUN failures appear during building, but invalid CMD commands can leave an image that fails only when run. section 12.2
  • Use separate platform-specific Dockerfiles when shared commands cannot support both Linux and Windows. section 12.2

A misleading multi-platform build

A folder-list Dockerfile can build successfully from a multi-platform base while mixing Linux and Windows commands. Running the resulting image then fails on every architecture because CMD contains invalid commands. section 12.2

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

How deep it goes
Explains base images, command compatibility, and build-versus-run failures, but stops short of complete publishing workflows.
Examples
Uses a folder-list image, Linux and Windows Dockerfiles, and amd64, arm64, and arm build-and-run commands.
What it assumes
Assumes basic Dockerfile and container commands while identifying Docker platform and CPU architecture names.
What you can do after
Build and verify architecture-specific image variants while detecting commands that fail only at container runtime.
How it connects
Connects multi-stage builds, image variants, platform architectures, and container emulation.

Related concepts

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.