Peter
Peter

Reputation: 1602

Docker buildx hangs when building image for arm64 using multi-stage Java build

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

Upvotes: 3

Views: 2280

Answers (1)

Noam Yizraeli
Noam Yizraeli

Reputation: 5424

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.

Upvotes: 3

Related Questions