码迷,mamicode.com
首页 > 其他好文 > 详细

docker构建JDK最小镜像

时间:2019-03-07 15:45:42      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:alpine   desktop   新建   container   ase   xpl   htm   aws   int   

一、构建最小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最小镜像

标签:alpine   desktop   新建   container   ase   xpl   htm   aws   int   

原文地址:https://www.cnblogs.com/sonfer/p/10489886.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!