2

I'm trying to build an arm64 Docker image for a Spring Boot app which uses multi-stage build. buildx or rather qemu hangs on unpacking step using jar -xf ../*.jar. One of the CPU cores uses 100% and the process runs infinitely. At the same time buildx can successfully build arm64 images for my non-Java projects. It may be due to something in buildx, qemu, jar, my app, or any combination of these. Please share ideas how to debug this?

.Dockerfile

FROM openjdk:8-jdk-alpine as build
WORKDIR /workspace/app
COPY build/libs/*.jar .
RUN mkdir -p unpacked && (cd unpacked; jar -xf ../*.jar) # <-- this is where qemu hangs

# Multi-stage build to split the dependencies and the app code into different layers
FROM openjdk:8-jdk-alpine
...etc ... these stage is not reached at all

The command for building the image: docker buildx build --platform linux/arm64,linux/amd64 -t mytag . --push

In the standard output this line is executed infinitely:

[linux/arm64 build 4/4] RUN mkdir -p unpacked && (cd unpacked; jar -xf ../*.jar)

I see the process running:

ps aux | grep jar
root       21965 99.9  0.0 201144 12928 ?        Ssl  23:10  39:06 /usr/bin/qemu-aarch64 /usr/lib/jvm/java-1.8-openjdk/bin/jar -xf ../myjar-0.0.1-SNAPSHOT.jar
Peter
  • 1,512
  • 1
  • 22
  • 40
  • Can you try with the full `openjdk:8-jdk` image? – Noam Yizraeli Sep 10 '21 at 08:31
  • 1
    Thanks Noam. It worked with the full image. If you add it as answer, I'll accept it. And if you know why it didn't work with alpine version, that'll be nice to share. – Peter Sep 10 '21 at 18:21
  • For sure, I think its because of the difference between most Linux distros using common c libraries and alpine using musl (it has caused errors before). I would like you to try the `openjdk:8-jdk-slim` version as well if possible and check if you can get some logs or the build process to provide a more complete and full solution – Noam Yizraeli Sep 10 '21 at 18:25
  • It worked with `slim` version either. The image size is almost twice smaller than with the full base image. Thank you! I guess I'll just go ahead with the slim version instead of alpine. – Peter Sep 10 '21 at 18:51
  • glad it helped created appropriate answer and will update on changes and improvements – Noam Yizraeli Sep 10 '21 at 18:57

1 Answers1

2

It's hard to tell but its probably one of the many problems alpine versioned docker images might have, here's a similar issue reported for python so it might be the same.

for the time being the recommended solution is to use the slim version of the debian version (openjdk:8-jdk-slim) if the size is cumbersome.

Noam Yizraeli
  • 4,446
  • 18
  • 35