Emulation reproduces another processor environment in software, letting Docker build or run containers for a different architecture than the host. Docker Desktop uses built-in QEMU support; Linux Docker Engine can use an installed QEMU setup. section 12.1 section 1.3
Use emulation when a development machine and target machine use different architectures, such as building an Arm64 image on an Intel computer. Build separate platform-tagged images, inspect their architectures, and run each image on a matching host. section 12.1
# switch to the exercises folder:
cd ch12/exercises
# build for 64-bit Arm:
docker build -t diamol/ch12-hello:2e-linux-arm64 `
--platform linux/arm64 ./hello
# and for 64-bit Intel:
docker build -t diamol/ch12-hello:2e-linux-amd64 `
--platform linux/amd64 ./hello
# check the native architecture of your engine:
docker info -f '{{.OSType}}/{{.Architecture}}'
# and the architecture of the images:
docker image inspect diamol/ch12-hello:2e-linux-arm64 `
-f '{{.Os}}/{{.Architecture}}'
docker image inspect diamol/ch12-hello:2e-linux-amd64 `
-f '{{.Os}}/{{.Architecture}}'
Build Arm64 and AMD64 images, inspect the engine architecture, and verify the architecture recorded in each image. section 12.1
Cross-platform image builds
A Go image built with the platform flag can target linux/arm64 or linux/amd64 even when the developer's machine supports only one architecture. The resulting images can be pushed to a registry and run on matching Arm or Intel machines. section 12.1
