下载Oracle官网的JRE包,最终下载的包如下:
jre-8u181-linux-x64.tar.gz
解压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
重新打包JRE目录下的所有文件
tar zcvf jre8.tar.gz *
创建Dockerfile
FROM frolvlad/alpine-glibc MAINTAINER baoyu RUN echo 'https://mirrors.ustc.edu.cn/alpine/latest-stable/main/' > /etc/apk/repositories && echo 'https://mirrors.ustc.edu.cn/alpine/latest-stable/community/' >>/etc/apk/repositories && apk update && apk --no-cache add tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone RUN mkdir /usr/local/dlfc_service WORKDIR /usr/local/dlfc_service ADD jre8.tar.gz /usr/java/jdk/ ENV JAVA_HOME /usr/java/jdk ENV PATH $PATH:$JAVA_HOME/bin
构建镜像
docker build -t reg.mystack.com/k8s/alpine-java:v1 .