使用alpine-glibc 构建jdk镜像

在使用使用alpine-glibc 构建oracle jdk 11镜像时,总是出现如下问题:

root@ubuntu22:/data/mydocker# docker run -it myjdk11
/ # java -version
java version "11" 2018-09-25
Java(TM) SE Runtime Environment 18.9 (build 11+28)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fbeb4cdc7f5[thread 12 also had an error]
, pid=7, tid=22
#
# JRE version: Java(TM) SE Runtime Environment (11.0+28) (build 11+28)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (11+28, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# [thread 13 also had an error]
C  [libc.so.6+0x1207f5][thread 10 also had an error]

#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to //core.7)
#
# An error report file with more information is saved as:
# //hs_err_pid7.log
[thread 17 also had an error]
[thread 14 also had an error]
[thread 8 also had an error]
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#
Aborted (core dumped)

我的Dockerfile 很简单

FROM frolvlad/alpine-glibc
#维护者信息
MAINTAINER  hph
 
COPY jdk-11 /usr/local/
 
ENV JAVA_HOME /usr/local/jdk-11
 
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
 
ENV PATH $PATH:$JAVA_HOME/bin

调研了一番
https://blog.51cto.com/dongweizhen/3770844
https://stackoverflow.com/questions/60014845/how-to-install-oracle-jdk11-in-alpine-linux-docker-image
https://blog.csdn.net/weixin_33713707/article/details/89702104

还是不行啊,算了就用这个吧
docker pull swr.ap-southeast-3.myhuaweicloud.com/oracle/jdk:11

有空分析下这个镜像
先下班··

记录一个升级jdk后的问题:
Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not “opens java.lang” to unnamed module @2c1b194a

由于 JDK 8 中有关反射相关的功能自从 JDK 9 开始就已经被限制了,为了兼容原先的版本,需要在运行项目时添加 --add-opens java.base/java.lang=ALL-UNNAMED 选项来开启这种默认不被允许的行为

启动时加上

java -cp /data Application  --spring.profiles.active=${PROFILE:=prod}  --add-opens java.base/java.lang=ALL-UNNAMED

你可能感兴趣的:(运维,java,jvm,开发语言)