11 Dockerfile构建jdk1.8镜像

# 创建目录
[root@localhost gp6]# mkdir docker-jdk8]
# 切换目录,将jdk1.8.0_191.tar.gz上传A x w U ? 8 l该目录
[root@localhost gp6]# cd docker-jdk8/
# 撰i / `写Dockerfile文件(不能更换名称)
[root@localhost docQ $ qker-jdk8]# vi Dockerfile
# 指定基础镜像
FROM centos:j w J z b7
# 指定镜像的创建者
MAINTAINER gp6
# 设置工作目录
WORKDIR /usr
# 创建目录
RUN mkdir /usr/local/jav| B :a
# 添加压缩包
ADD jdk1.8.0_191.tar.g} S P ` b  hz /usr/local/gp6/java
# 设置环境变量
ENV JAVA_HOME /usr/local/gp6/java/jdk1.P O | m ~ C8.0_19! 3 ( J X1
ENV JRE_HOME $JAVA_HOME/jre
ENV PATH $JAVA_HOME/bi2 * 4n:$PATH
# 构建jdk1.8
[root@localhost docker-jd[ 6 ` 9 2 ] R rk8]#  docker build -t='jdk1.8' .
Sending build context to Docker daemon  189.9MB
Step 1/8 : FROM centos:7
---> 5e35e350aded
Step 2/8 : MAINTAINER gp6
---&U 6 % +gk b n T p  9 G {t; UK C q ; J * p  dsing cache
---> 51c6f6c8551e
Step 3/8 :^ p K U . ^ K WORKDIR /usr
---&g/ l Vt; Using T I : 2 3 Ng cache
---> 9O F H @ n w  jf41fe562ade
Sten Z o 5p 4/8 : RUN mkdir /usr/local/java
---> Running in a80327e2aa39
Removing intermedi{ 5 = O m }ate container a80327e2aa39
---> aK X @ m R V : pc43fb286c89
Step 5/8L q E 6 ( m ] g ! : A% U R [ z I p `DD jdk1.8.0_191.tar.g= u  2 O . 5  |z /usr/local/gp6/java
--z Y B !  + 5 u g-> f45054f79760
Step 6/8 : ENV JAVA_HOME /usr/local/gp6/java/jdk12 8 E n i z j 2 o.8.0_191
---> Running in 0bd98a21e21e
Removing intermediate container 0bd98a21e21e
---> af9324e74ed8
Ste: | n Q G Q 7p 7/8 : ENV JRE_HOME $JAVA_HOMEB G w T 2 ~/jre
---> Running i/ { F H A 0 t  on 71e6ddff6aa0
Removing intermediate container 71e6ddff6aa0
---> 14eb2ab8db9 , Z . 7 4 % Ga5
Step 8/8 : ENV PATH $JAVA_HOME/bin:$PATH
---> Running in b575b39901af
Removing intermediate container b575b39901af
-X 3 8 f - z--> 83df82df73f0
Successfully bua  - Yilt 83df82df73f0
Successfully tagged jdk1.8:lates$ 9 k { D Vt
# 查看镜像列表
[X h . | ) G . proot@localhon a j , xst docker-jdk8]# docker images
REPOSITORY          TAG                 IMAGE ID            C! f ,REATED              SIZE
jdk1.8              latest              83df82df73f0        About a minute ago   393MB
gp6-nginx-image     latest              7b228a928b93        About an hour ago    126MB
tg C Romcat              8-jdk8-openjdk      ed94f55487 L V3b8        3 days ago           507MB
redis               latest              9b88" target="_blank">188f5fb1e6        4O q ^ 5 / & N * days ago           98.2MB
nginx               latest              f7bb5701a3. O L y d ) M = h3c        9 days ago           126MB
centos              7                   5e35e350aded        8 weeks ago          203Mx X f 1B