Sub topic 1
Platforms: OS, architecture and variant
A container image holds compiled programs, so it only runs on the kind of machine it was built for. This chapter defines how Docker and OCI registries name that kind of machine. Later chapters rely on these names.
Prerequisites
This chapter assumes you can build, run, tag and push images with Docker. It also assumes you can read a simple Dockerfile, know what a registry and a tag are, and know that CPUs differ in architecture, such as x86-64 and ARM.
The platform string
A platform identifies the environment an image's binaries expect. It has up to three parts, written as os/architecture/variant.
- OS is the operating system kernel interface the binaries use, such as
linuxorwindows. - Architecture is the CPU instruction set, such as
amd64orarm64. - Variant is an optional refinement within an architecture, such as
v7for 32-bit ARM.
Containers share the host kernel. That is why the OS part matters: a Linux image needs a Linux kernel. Docker Desktop on macOS and Windows runs a small Linux virtual machine, so it runs linux/* images.
Common platforms
| Platform | Typical hardware |
|---|---|
| `linux/amd64` | Intel and AMD servers and PCs (x86-64) |
| `linux/arm64` | AWS Graviton, Apple Silicon, 64-bit Raspberry Pi OS |
| `linux/arm/v7` | 32-bit ARM boards, older Raspberry Pi systems |
| `linux/386` | 32-bit x86 |
| `windows/amd64` | Windows containers on x86-64 |
For linux/arm64, the variant is v8. It is usually left out of the platform string, because 64-bit ARM has one common variant. For 32-bit ARM, v6 and v7 are different targets, so the variant must be stated.
Names differ between tools
The same CPU has different names in different tools. Docker and OCI use the names that the Go language uses. The uname -m command reports the kernel's name.
| Docker and OCI name | `uname -m` output |
|---|---|
| `amd64` | `x86_64` |
| `arm64` | `aarch64` |
Mixing these up is a common error. A --platform linux/x86_64 flag may be accepted as an alias in some tools. Write amd64 in your own commands and Dockerfiles.
Seeing the platform
Your Docker engine has a platform, and so does every image you pull. Check the engine first.
docker version --format '{{.Server.Os}}/{{.Server.Arch}}'On an Apple Silicon laptop this prints linux/arm64. On an Intel server it prints linux/amd64.
An image's platform is stored in its configuration, so you can read it after pulling.
docker pull alpine:3.20
docker image inspect --format '{{.Os}}/{{.Architecture}}' alpine:3.20Choosing a platform explicitly
By default, Docker uses the host's platform. The --platform flag overrides that. The next commands use one multi-platform tag and show which variant ran.
docker run --rm --platform linux/arm64 alpine:3.20 uname -m
docker run --rm --platform linux/amd64 alpine:3.20 uname -mThe first command prints aarch64 and the second prints x86_64. This works on any host only if the tag offers an image for each platform. If the host's CPU differs from the requested platform, the binaries run only when emulation is set up. Emulation is covered in a later chapter.
Common mistakes
- Using
x86_64oraarch64where Docker expectsamd64orarm64. - Assuming "arm" means 64-bit. Plain
armis 32-bit and needs a variant such asv7. - Forgetting that the engine's platform, not your shell's, decides the default. With a remote Docker host,
docker versionshows the remote engine. - Leaving out the OS.
--platform arm64is less clear than--platform linux/arm64.
Exercise
You run uname -m inside a container and see aarch64. Which Docker platform string describes that image, and what would you write for an Intel server?
Show answer
The image is linux/arm64, because aarch64 is the kernel's name for arm64. The Intel server platform is linux/amd64, which uname -m reports as x86_64.