1

问题

我的任何 SpringBoot 应用程序都可以在 Alpine 3.8 上的 JDK 8、JDK 11 和 JDK 12 中运行

Alpine 和 JDK 的设置

这是我正在使用的 Dockerfile

FROM alpine:3.8

# ca certificates: to support HTTPS calls to other services
# hadolint ignore=DL3008
RUN apk update && \
    apk add bash ca-certificates openssl --no-cache

RUN update-ca-certificates

ENV JAVA_HOME=/opt/jdk-custom/jre
ENV PATH="$PATH:$JAVA_HOME/bin"

OpenSSL 调用的分段错误

分段错误如下:

    ---------------  S U M M A R Y ------------

    Command Line: -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:+UseStringDeduplication -XX:MaxRAMFraction=2 -XX:+HeapDumpOnOutOfMemoryError -XX:ErrorFile=/runtime/logs/error.log -XX:HeapDumpPath=/runtime/logs/error.heap.hprof -XX:+UnlockExperimentalVMOptions -Djdk.module.showModuleResolution=true -Djava.security.egd=file:/dev/./urandom /runtime/server.jar

    Host: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz, 6 cores, 7G, Alpine Linux v3.8
    Time: Sun Nov 18 15:28:22 2018 UTC elapsed time: 8 seconds (0d 0h 0m 8s)

    ---------------  T H R E A D  ---------------

    Current thread (0x000055e8239a7800):  JavaThread "main" [_thread_in_native, id=43, stack(0x00007f524b58f000,0x00007f524b68fab0)]

    Stack: [0x00007f524b58f000,0x00007f524b68fab0],  sp=0x00007f524b68c6d8,  free space=1013k
    Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C  0x0000000000000e16

    Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
    j  org.apache.commons.crypto.cipher.OpenSslNative.initIDs()V+0
    j  org.apache.commons.crypto.cipher.OpenSsl.<clinit>()V+8
    v  ~StubRoutines::call_stub
    j  org.apache.commons.crypto.cipher.OpenSslCipher.<init>(Ljava/util/Properties;Ljava/lang/String;)V+14
    v  ~StubRoutines::call_stub
  org.springframework.boot.SpringApplication.applyInitializers(Lorg/springframework/context/ConfigurableApplicationContext;)V+50
    j  org.springframework.boot.SpringApplication.prepareContext(Lorg/springframework/context/ConfigurableApplicationContext;Lorg/springframework/core/env/ConfigurableEnvironment;Lorg/springframework/boot/SpringApplicationRunListeners;Lorg/springframework/boot/ApplicationArguments;Lorg/springframework/boot/Banner;)V+14
    j  org.springframework.boot.SpringApplication.run([Ljava/lang/String;)Lorg/springframework/context/ConfigurableApplicationContext;+86
    j  org.springframework.boot.SpringApplication.run([Ljava/lang/Object;[Ljava/lang/String;)Lorg/springframework/context/ConfigurableApplicationContext;+9
    j  org.springframework.boot.SpringApplication.run(Ljava/lang/Object;[Ljava/lang/String;)Lorg/springframework/context/ConfigurableApplicationContext;+9

    v  ~StubRoutines::call_stub
    j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@11-ea
    j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100 java.base@11-ea
    j  jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6 java.base@11-ea
    j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+59 java.base@11-ea
    j  org.springframework.boot.loader.MainMethodRunner.run()V+43
    j  org.springframework.boot.loader.Launcher.launch([Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)V+14
    j  org.springframework.boot.loader.Launcher.launch([Ljava/lang/String;)V+19
    j  org.springframework.boot.loader.WarLauncher.main([Ljava/lang/String;)V+8
    v  ~StubRoutines::call_stub
4

1 回答 1

0

解决方案

这是更新的 Dockerfile

来自高山:3.8

# ca certificates: to support HTTPS calls to other services
# hadolint ignore=DL3008
RUN apk update && \
    apk add bash ca-certificates libressl libressl-dev --no-cache

RUN update-ca-certificates

ENV JAVA_HOME=/opt/jdk-custom/jre
ENV PATH="$PATH:$JAVA_HOME/bin"
于 2018-12-04T19:10:25.403 回答