docker通过alpine制作最小的jdk镜像
一 删除jdk中用不到的文件
rm -rf /usr/soft/jdk1.8.0_221/*src.zip \
/usr/soft/jdk1.8.0_221/lib/missioncontrol \
/usr/soft/jdk1.8.0_221/lib/visualvm \
/usr/soft/jdk1.8.0_221/lib/*javafx* \
/usr/soft/jdk1.8.0_221/jre/lib/plugin.jar \
/usr/soft/jdk1.8.0_221/jre/lib/ext/jfxrt.jar \
/usr/soft/jdk1.8.0_221/jre/bin/javaws \
/usr/soft/jdk1.8.0_221/jre/lib/javaws.jar \
/usr/soft/jdk1.8.0_221/jre/lib/desktop \
/usr/soft/jdk1.8.0_221/jre/plugin \
/usr/soft/jdk1.8.0_221/jre/lib/deploy* \
/usr/soft/jdk1.8.0_221/jre/lib/*javafx* \
/usr/soft/jdk1.8.0_221/jre/lib/*jfx* \
/usr/soft/jdk1.8.0_221/jre/lib/amd64/libdecora_sse.so \
/usr/soft/jdk1.8.0_221/jre/lib/amd64/libprism_*.so \
/usr/soft/jdk1.8.0_221/jre/lib/amd64/libfxplugins.so \
/usr/soft/jdk1.8.0_221/jre/lib/amd64/libglass.so \
/usr/soft/jdk1.8.0_221/jre/lib/amd64/libgstreamer-lite.so \
/usr/soft/jdk1.8.0_221/jre/lib/amd64/libjavafx*.so \
/usr/soft/jdk1.8.0_221/jre/lib/amd64/libjfx*.so
二 制作 dockerfile
FROM alpine:latest
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.9/main/" > /etc/apk/repositories && \
apk --no-cache add ca-certificates wget && \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk && \
apk add glibc-2.30-r0.apk && \
rm -rf *.apk && \
rm -rf /var/cache/apk/*
ADD jdk1.8.0_221 /usr/java/jdk
# Set environment
ENV JAVA_HOME=/usr/java/jdk
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH=${PATH}:${JAVA_HOME}/bin
三 创建镜像
docker build --rm -t alpine-jdk .
四 创建实例运行
docker run -it --name myjdk alpine-jdk
2021-10-06 22:21:00
共有0条评论!