docker优化jdk8镜像

1、精简jre8

tar zxf jre-8u211-linux-x64.tar.gz
 cd jre1.8.0_211
 rm -rf COPYRIGHT LICENSE README release THIRDPARTYLICENSEREADME-JAVAFX.txt THIRDPARTYLICENSEREADME.txt Welcome.html
    rm -rf   lib/plugin.jar \
             lib/ext/jfxrt.jar \
             bin/javaws \
             lib/javaws.jar \
             lib/desktop \
             plugin \
             lib/deploy* \
             lib/*javafx* \
             lib/*jfx* \
             lib/amd64/libdecora_sse.so \
             lib/amd64/libprism_*.so \
             lib/amd64/libfxplugins.so \
             lib/amd64/libglass.so \
             lib/amd64/libgstreamer-lite.so \
             lib/amd64/libjavafx*.so \
             lib/amd64/libjfx*.so

    tar zcvf jre8.tar.gz *
    mv jre8.tar.gz  ../

2、构建镜像的Dockerfile

# using alpine-glibc instead of alpine  is mainly because JDK relies on glibc
FROM frolvlad/alpine-glibc
# author
MAINTAINER ygsama@qq.com
# A streamlined jre
ADD jre8.tar.gz /usr/java/jdk/
ADD msyhbd.ttc  /opt/
ADD msyhl.ttc   /opt/
ADD msyh.ttc    /opt/
ADD simhei.ttf  /opt/
ADD simkai.ttf  /opt/
ADD simsun.ttc  /opt/
# set env
ENV JAVA_HOME /usr/java/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin
ENV CLASSPATH ${CLASSPATH}:${JAVA_HOME}/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
# run container with base path:/opt
WORKDIR /opt
# install font
RUN apk add font-adobe-100dpi \
    && chmod 777 *.ttc \
    && chmod 777 *.ttf \
    && mkdir /usr/share/fonts/win \
    && mv msyhbd.ttc /usr/share/fonts/win/  \
    && mv msyhl.ttc  /usr/share/fonts/win/  \
    && mv msyh.ttc   /usr/share/fonts/win/  \
    && mv simhei.ttf /usr/share/fonts/win/  \
    && mv simkai.ttf /usr/share/fonts/win/  \
    && mv simsun.ttc /usr/share/fonts/win/  \
    && fc-cache -f \
    && fc-list

3、准备微软雅黑、楷体、宋体等

4、构建jre镜像

docker build -t haft/jre:8 .
posted @ 2024-02-21 14:43  IT终结者  阅读(145)  评论(0编辑  收藏  举报