1、下载Oracle官网的JRE包,最终下载的包如下:

jre-8u181-linux-x64.tar.gz

2、解压JRE包并删除不必要的文件

#解压
tar xf jre-8u181-linux-x64.tar.gz
#进入目录
cd jre1.8.0_181/
#删除文本文件
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

3、重新打包JRE目录下的所有文件

tar zcvf jre8.tar.gz *

4、创建Dockerfile

FROM frolvlad/alpine-glibc

MAINTAINER devops(devops@example.com)
 
RUN apk update && apk --no-cache add tzdata ttf-dejavu fontconfig \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone
 
ENV LANG=en_US.UTF-8 \
    LANGUAGE=en_US.UTF-8

ADD jre8.tar.gz /usr/java/jdk/

ENV JAVA_HOME /usr/java/jdk
ENV PATH $PATH:$JAVA_HOME/bin
 
RUN mkdir -p $JAVA_HOME/lib/fonts/fallback/ \
    && cd $JAVA_HOME/lib/fonts/fallback/ \
    && wget http://b.pig4cloud.com/SIMSUN.TTC

RUN mkdir -p /data/server
WORKDIR /data/server

5、构建镜像

docker build -t reg.istack.com/k8s/alpine-java:v1 .

 

posted on 2018-10-31 15:30  a120608yby  阅读(990)  评论(0编辑  收藏  举报