Skip to content

Instantly share code, notes, and snippets.

@carlohcs
Last active July 28, 2024 14:55
Show Gist options
  • Save carlohcs/6f690536a3b5efa7b8b051162c19b986 to your computer and use it in GitHub Desktop.
Save carlohcs/6f690536a3b5efa7b8b051162c19b986 to your computer and use it in GitHub Desktop.
Build docker image on Mac (M1/M2/M3)

Issue - Cannot build correctly an image at Docker on Mac with M1/M2/M3

In order to avoid errors like:

exec /usr/local/openjdk-11/bin/java: exec format error

or

WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and a specific platform was not requested
exec /usr/local/openjdk-11/bin/java: exec format error

Solve with

docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64 . -t <image-name> --push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment