1

我正在尝试为使用多阶段构建的 Spring Boot 应用程序构建 arm64 Docker 映像。buildx或者更确切地说qemu,使用jar -xf ../*.jar. 其中一个 CPU 核心使用 100%,进程无限运行。同时buildx可以为我的非Java项目成功构建arm64镜像。这可能是由于 buildx、qemu、jar、我的应用程序或这些的任何组合中的某些内容。请分享想法如何调试?

.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

构建镜像的命令:docker buildx build --platform linux/arm64,linux/amd64 -t mytag . --push

在标准输出中,这一行被无限执行:

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

我看到进程正在运行:

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
4

1 回答 1

1

很难说,但它可能是版本化的alpinedocker 镜像可能存在的众多问题之一,这里有一个针对 python 报告的类似问题,所以它可能是相同的。

暂时推荐的解决方案是,openjdk:8-jdk-slim如果体积比较笨重,就使用 debian 版本的 slim 版本( )。

于 2021-09-10T18:56:07.707 回答