ankit dadhich
ankit dadhich

Reputation: 1

quarkus native image failing with "exec ./application: exec format error"

facing this issue, getting below error, when i try to follow [https://quarkus.io/guides/building-native-image]

and build native image for quarkus app and run its docker image,

exec ./application: exec format error

i am using mac M1, with below java and maven versions

ad@ad-MacBook-Pro code-with-quarkus % mvn --version Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /usr/local/Cellar/maven/3.8.6/libexec Java version: 18.0.1.1, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/18.0.1.1/libexec/openjdk.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "11.4", arch: "x86_64", family: "mac"

ad@ad-MacBook-Pro code-with-quarkus % java --version openjdk 17.0.3 2022-04-19 OpenJDK Runtime Environment GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06) OpenJDK 64-Bit Server VM GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06, mixed mode, sharing) ad@ankits-MacBook-Pro code-with-quarkus %

i have performed steps

  1. quarkus app was working locally

  2. installed grallVM (able to run basic hello world program natively)

  3. ./mvnw package -Pnative

  4. ./mvnw package -Pnative -Dnative-image.docker-build=true

  5. docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-project . until now all worked

  6. docker run -i --rm -p 8080:8080 quarkus/quarkus-project this is failing with error (exec ./application: exec format error )

can somebody point out what i am doing wrong, thanks in advance.

Upvotes: 0

Views: 694

Answers (2)

BitfulByte
BitfulByte

Reputation: 4446

I am using the quarkus-container-image-jib extension and running from an M1 macbook. I had the same issue. When I look at the container image in docker I notice it says it was for AMD64.

After I added -Dquarkus.jib.platforms=linux/arm64/v8 to the command line argument the AMD64 label disappeared and the container worked:

full command used: ./mvnw clean install -Pnative -DskipTests -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true -Dquarkus.jib.platforms=linux/arm64/v8

For more details about building container images, see https://quarkus.io/guides/container-image#building

Upvotes: 0

martosfre
martosfre

Reputation: 874

I had this error related to building a native image:

enter image description here

The error was because I had installed an x64 JDK version instead AARCH64 JDK. In my case use Amazon Corretto.

Upvotes: 0

Related Questions