Sping Boot 应用程序在Docker容器中崩溃(但不在cmd行)

wqsoz72f  于 2023-01-25  发布在  Docker
关注(0)|答案(1)|浏览(171)

我有一个小型的Sping Boot rest服务,它可以很好地运行:

java -jar myapp.jar

...但是当我在Docker容器中部署时,当我使用curl访问服务时,它会使容器崩溃:
Java运行时环境检测到致命错误:
在pc= 0x 00007 f052205991 a,pid=1,tid=40时的信号隔离(0xb)
JRE版本:OpenJDK运行时环境Temurin-19.0.1+10(19.0.1+10)(内部版本19.0.1+10)Java虚拟机:OpenJDK 64位服务器VM Temurin-19.0.1+10(19.0.1+10,混合模式,共享,分层,压缩的oops,压缩的类pt〉有问题的帧:V [libjvm.so+0xe2f91a]虚拟机句柄Linux信号+0x13a
停靠文件:

FROM amd64/eclipse-temurin:19.0.1_10-jre-alpine
VOLUME /opt/galleries
RUN mkdir -p /opt/rest.galleries/logs/
ARG JAR_FILE
ADD ${JAR_FILE} /opt/rest.galleries/app.jar
EXPOSE 8000
ENTRYPOINT ["java","-jar","/opt/rest.galleries/app.jar"]

从图像创建容器:

docker run -p 8000:8000 -v /opt/galleries:/opt/galleries --memory="1g" --memory-swap="2g" -t craigfoote/rest.galleries:latest &

我正在使用这些库来读取webp和jpg图像。:

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-imaging</artifactId>
    <version>1.0-alpha3</version>
</dependency>
<dependency>
    <groupId>org.sejda.imageio</groupId>
    <artifactId>webp-imageio</artifactId>
    <version>0.1.6</version>
</dependency>

我正在通过以下方式构建图像:

<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>1.4.13</version>
    <executions>
        <execution>
            <id>default</id>
            <goals>
                <goal>build</goal>
                <goal>push</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <repository>${project.artifactId}</repository>
        <tag>${project.version}</tag>
        <buildArgs>
            <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
        </buildArgs>
    </configuration>
</plugin>

它崩溃的点是调用:

ImageIO.read(file); // where file is a 238kB webp image

由于它在cmd行工作,我假设代码操作本身不是问题,但它可能是导致它,也许是内存问题?我试图修改docker运行命令,以增加内存和交换,但它没有帮助:

docker run -p 8000:8000 -v /opt/galleries:/opt/galleries --memory="4g" --memory-swap="8g" -t craigfoote/rest.galleries:latest &

当崩溃发生时,控制台指出hs_err_pid1.log文件已写入,但我找不到它。
有什么想法吗?

sqougxex

sqougxex1#

基本映像amd 64/eclipse-temurin:19.0.1_10-jre-alpine使用的libc与org.sejda.imageio:webp-imageio不同。我改用ubuntu base并安装openjdk-19,现在一切正常。

FROM ubuntu:latest
RUN apt update && \
    apt install -y openjdk-19-jdk ca-certificates-java && \
    apt clean && \
    update-ca-certificates -f
ENV JAVA_HOME /usr/lib/jvm/java-19-openjdk-amd64/
RUN export JAVA_HOME
VOLUME /opt/galleries
RUN mkdir -p /opt/rest.galleries/logs/
ARG JAR_FILE
ADD ${JAR_FILE} /opt/rest.galleries/app.jar
EXPOSE 8000
ENTRYPOINT ["java","-jar","/opt/rest.galleries/app.jar"]

相关问题