How to build amd64 docker images on Apple Silicon


If you’re on Apple Silicon, it’s likely that the infrastructure that you deploy your code onto is using amd64 instead of arm. This means that docker images you build on your computer won’t be able to execute on your servers.

You might run into an error that looks like this:

exec user process caused: exec format error

To fix it, you’ll have to rebuild your docker image for amd64.

Instead of:

docker build .

You’ll need to use:

docker buildx build --platform linux/amd64 .

You may also pass in multiple architectures at once by separating them with a comma like this:

docker buildx build --platform linux/amd64,linux/arm64 .