Methods
Emulation
Using QEMU which is provided with Docker Desktop.
The image used in FROM
must be available on the target platform.
Cross-compilation
Using image provided capabilities to cross-compile.
GOOS
and GOARCH
for Go build
commandGo.
Use ARG
s provided by Docker:
Set using --platform
flag in build
command.
BUILDPLATFORM
- platform of the host running the buildBUILDOS
- OS part of theBUILDPLATFORM
BUILDARCH
- arch part of theBUILDPLATFORM
TARGETPLATFORM
- target platformTARGETOS
- OS part of theTARGETPLATFORM
TARGETARCH
- architecture part of theTARGETPLATFORM
Examples
go
uses different Dockerfile
for each arch/OS variant. See: docker library/golang
hello-world
uses the same approach: docker-library/hello-world