'Building quarkus native Linux/amd64 (x86_64) image from Apple M1 (Arm)

I am trying to build Quarkus 2.8.0 for x86 platfom of native docker container from Apple M1 Macbook and deploy it in Linux amd64 Portainer. I was able to build the native image and when checking the file

file target/simple-app-1.0.0-SNAPSHOT-runner

the output is:

target/simple-app-1.0.0-SNAPSHOT-runner: Mach-O 64-bit executable x86_64

And then I am building docker container using Dockerfile.native-micro file, and push to my local registry using this command:

docker buildx build -t local-registry/repo/simple-app:latest-x86_64 -f src/main/docker/Dockerfile.native-micro --push --platform=linux/amd64 .

The build process finished successfully without error or warning, and when I check in the local registry the container is created.

The problem appear when I was trying to deploy the container in my Linux amd64 server with Portainer. The container is unable to start, and the log output is:

standard_init_linux.go:219: exec user process caused: exec format error


Solution 1:[1]

The native image that you created is Mac native, it will not run in Linux. You should rather build your image using

quarkus build --native -Dquarkus.native.container-build=true

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Faisal Khan