docker构建JDK最小镜像
Posted sonfer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker构建JDK最小镜像相关的知识,希望对你有一定的参考价值。
一、构建最小JDK
1、解压jre
# mv jre-8u181-linux-x64.tar.gz java1.8.tar.gz # tar -xvcf jre-8u181-linux-x64.tar.gz
2、删除无用文件
# 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、重新打包
# tar acf java1.8.tar.gz java1.8
4、新建Dockerfile
# using alpine-glibc instead of alpine is mainly because JDK relies on glibc FROM docker.io/jeanblanchard/alpine-glibc # author MAINTAINER simon # A streamlined jre ADD java1.8.tar.gz /usr/java/jdk/ # set env ENV JAVA_HOME /usr/java/jdk ENV PATH ${PATH}:${JAVA_HOME}/bin # run container with base path:/opt WORKDIR /opt
5、构建docker镜像
docker build -t simon/java8:1.0 .
这样构建的镜像大概120M左右
以上是关于docker构建JDK最小镜像的主要内容,如果未能解决你的问题,请参考以下文章