I'm attempting to build a docker image locally on my m1 mac. The application inside of the docker image is a java application built with jlink
.
When attempting to run the docker image with the java application embedded in it, i get an error saying No java detected
.
When I enter into the container, and try to do ./jre/bin/java -version
, I get this error from Java
bitcoin-s@d672864e1b18:/opt/docker$ ./jre/bin/java
bash: ./jre/bin/java: cannot execute binary file: Exec format error
However this is confusing to me, as I said in the title, this is built on an m1 mac with java that supports aarch64. I would imagine the jre produced by jlink
would also support aarch64
in the docker image?
Too be clear, i am running attempting to build AND run the docker image on the same host machine which is an m1 mac.
If its relevant, the version of java I am using on my m1 mac is
java -version
openjdk version "17.0.2" 2022-01-18 LTS
OpenJDK Runtime Environment Zulu17.32+13-CA (build 17.0.2+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.32+13-CA (build 17.0.2+8-LTS, mixed mode, sharing)
When I pull a remotely built linux version of the docker container, and attempt to run java inside the container, I get this error
./jre/bin/java -version
/lib64/ld-linux-x86-64.so.2: No such file or directory
This is a duplicate of JLink does not produce redistributable image
TLDR, the linker expected by jlink was an x86 linker /lib64/ld-linux-x86-64.so.2
, however since the CPU that i'm attemping to run the jlink'ed jre on is an arm64 CPU, it does not have a x86 linker.
The root cause of this is the fact that I built the jre on an x86 github actions machine, and tried to run this on an arm64 machine.
At minium, it would be really nice to have an improved error message for this by the jdk teams.
One absolutely baffling error message is
bash: ./jre/bin/java: cannot execute binary file: Exec format error
If you found this question, here is where you can track our teams workarounds for this: