quarkus: Error starting native application container in distroless docker image
Describe the bug I have an application which I want to build in a distroless Docker image. I follow this README and the container doesn’t start.
Expected behavior The container should start fine.
Actual behavior The container doesn’t start getting ´standard_init_linux.go:211: exec user process caused "exec format error"´ error message.
To Reproduce Steps to reproduce the behavior:
- Go to project root folder
- Build it with
./mvnw clean package -Pnative -Dnative-image.docker-build=true
as I can read in the README above. - Build the Docker image with:
docker build -f src/main/docker/Dockerfile.distroless -t employee-distroless:1.0.1 .
. - Finally, try to start the container with:
docker run -i --rm -p 8080:8080 employee-distroless:1.0.1
.
Environment (please complete the following information):
- Output of
java -version
: I use docker-build flag. - GraalVM version (if different from Java): I use docker-build flag.
- Quarkus version: 1.4.1.Final
- Build tool (ie. output of
mvnw --version
orgradlew --version
):
./mvnw --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/sa23xj/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 1.8.0_202, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre
Default locale: en_ES, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 2
- Comments: 19 (8 by maintainers)
Hello I have managed to build a distroless image 😃
Here is the code :
@cescoffier What do you think about this approach ? I could document it here if you want : https://github.com/quarkusio/quarkus-images/tree/master/distroless
Here is a working example : https://github.com/maxday/quarkus-native-distroless
I think the difference I that when you build
./gradlew build -Dquarkus.package.type=native
on a Mac, it will compile it to Mac byte code, which then after being copied to docker is no longer compatible with linux. By doing./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
you are actually building it with docker for linux which makes the binary no longer runnable on Mac but it runs after copying to linux.@serrodcal Sorry, it was very late (2:20 am my time). I should have explained that when i used
-Dquarkus.native.container-build=true
, Docker downloaded a dependency that it didnt when I used-Dnative-image.docker-build=true
so it might be the missing library =)oh I see that @matthyx is doing exactly that here https://github.com/quarkusio/quarkus-images/pull/118
I also think the builder approach is nice 👍🏼
Tested and working fine!
Thanks @maxday
Nice @maxday! I like the idea to use another container to extract the .so files.