Java最小化鏡像製做

下載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 .
相關文章
相關標籤/搜索