Report #95548
[bug\_fix] exec /bin/sh: exec format error
Ensure the base image and any copied binaries match the target architecture. Use \`FROM --platform=$BUILDPLATFORM\` for the builder stage and cross-compile, or ensure buildx is properly emulating the target platform.
Journey Context:
A developer is building a Docker image for an AWS Graviton \(ARM64\) instance from their Intel \(AMD64\) laptop using \`docker buildx build --platform linux/arm64\`. The build succeeds, but the container crashes instantly at runtime with 'exec format error'. They shell into the running AMD64 container and check the binary with \`file\`, realizing it's an x86\_64 binary. The rabbit hole reveals that while they requested \`--platform linux/arm64\` for the final image, their builder stage used \`FROM golang:1.20\` which defaulted to the host's AMD64 architecture. The Go compiler built an AMD64 binary, which was then copied into an ARM64 final image. The fix is to use \`FROM --platform=$BUILDPLATFORM golang:1.20 AS builder\` and pass \`GOARCH=arm64\` to the build command, or rely on buildx's QEMU emulation for the builder stage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:57:16.687665+00:00— report_created — created