前提:目前大部分的java images都是根据centos和Ubuntu做的,结果是镜像非常大,基本上300-500m,太影响docker的使用了。
思路:换更加轻量级的linux系统,删除jdk中无关的东西
先下载jdk的tar包,然后删除jdk中无关的东西
将jdk1.6.0_33.tgz 解压到 /usr/java/jdk
rm -rf /usr/java/jdk/*src.zip /usr/java/jdk/lib/missioncontrol /usr/java/jdk/lib/visualvm /usr/java/jdk/lib/*javafx* /usr/java/jdk/jre/lib/plugin.jar /usr/java/jdk/jre/lib/ext/jfxrt.jar /usr/java/jdk/jre/bin/javaws /usr/java/jdk/jre/lib/javaws.jar /usr/java/jdk/jre/lib/desktop /usr/java/jdk/jre/plugin /usr/java/jdk/jre/lib/deploy* /usr/java/jdk/jre/lib/*javafx* /usr/java/jdk/jre/lib/*jfx* /usr/java/jdk/jre/lib/amd64/libdecora_sse.so /usr/java/jdk/jre/lib/amd64/libprism_*.so /usr/java/jdk/jre/lib/amd64/libfxplugins.so /usr/java/jdk/jre/lib/amd64/libglass.so /usr/java/jdk/jre/lib/amd64/libgstreamer-lite.so /usr/java/jdk/jre/lib/amd64/libjavafx*.so /usr/java/jdk/jre/lib/amd64/libjfx*.so
以下dockerfile 基于 AlpineLinux
#Alpine Linux with a glibc-2.21 and Oracle Java 7 FROM docker.io/jeanblanchard/alpine-glibc #MAINTAINER Fox Chan #Java Version #ENV JAVA_VERSION_MAJOR 7 #ENV JAVA_VERSION_MINOR 60 #ENV JAVA_PACKAGE jdk #install java ADD jdk /usr/java/jdk # Set environment ENV JAVA_HOME /usr/java/jdk ENV PATH ${PATH}:${JAVA_HOME}/bin
才 158.3 MB,太酷了!
时间: 2024-10-27 08:08:04