Dockerfile常用命令
微信图片_20190815190536.pngDockerfile 构建JDK1.8镜像
- 从oracle官网下载jdk-8u172-linux-x64.tar.gz,并上传到服务器/usr/local/dockerjdk8/目录下 (没有就新建目录)
- 创建Dockerfile文件,并编辑
[root@iz2zegpdc9x4o0ir42a2upz local]# cd dockerjdk8/
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# ls
jdk-8u172-linux-x64.tar.gz
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# vi Dockerfile
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# cat Dockerfile
FROM centos:7
MAINTAINER hehongqian
WORKDIR /usr
RUN mkdir /usr/local/java
ADD jdk-8u172-linux-x64.tar.gz /usr/local/java
ENV JAVA_HOME /usr/local/java/jdk1.8.0_172
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH $JAVA_HOME/bin/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
ENV PATH $JAVA_HOME/bin:$PATH
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# docker build -t='jdk1.8' .
Sending build context to Docker daemon 190.9MB
Step 1/9 : FROM centos:7
---> 9f38484d220f
Step 2/9 : MAINTAINER hehongqian
---> Running in 4e9d40b0f597
Removing intermediate container 4e9d40b0f597
---> abe1aa91adbe
Step 3/9 : WORKDIR /usr
---> Running in 1bd2a9717955
Removing intermediate container 1bd2a9717955
---> 99193dc1ff55
Step 4/9 : RUN mkdir /usr/local/java
---> Running in 2482d41e8b58
Removing intermediate container 2482d41e8b58
---> b6d1b9ae778c
Step 5/9 : ADD jdk-8u172-linux-x64.tar.gz /usr/local/java
---> ba70d89de032
Step 6/9 : ENV JAVA_HOME /usr/local/java/jdk1.8.0_172
---> Running in 84e05c4694e8
Removing intermediate container 84e05c4694e8
---> 971d9c02287c
Step 7/9 : ENV JRE_HOME $JAVA_HOME/jre
---> Running in ba81ce7f19b2
Removing intermediate container ba81ce7f19b2
---> ef94124823b6
Step 8/9 : ENV CLASSPATH $JAVA_HOME/bin/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
---> Running in 4a7b9d4bd414
Removing intermediate container 4a7b9d4bd414
---> f65d2a2f678c
Step 9/9 : ENV PATH $JAVA_HOME/bin:$PATH
---> Running in 1d33f891be87
Removing intermediate container 1d33f891be87
---> b5984b02f4fb
Successfully built b5984b02f4fb
Successfully tagged jdk1.8:latest
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jdk1.8 latest b5984b02f4fb 3 minutes ago 589MB
redis latest f7302e4ab3a8 36 hours ago 98.2MB
nginx latest 4733136e5c3c 43 hours ago 126MB
tomcat 7-jre7 47c156f4d4e3 3 months ago 359MB
centos/mysql-57-centos7 latest e35b3f7a4ea0 4 months ago 452MB
centos 7 9f38484d220f 5 months ago 202MB
[root@iz2zegpdc9x4o0ir42a2upz dockerjdk8]#
可以看到jdk1.8的镜像已经成功创建了
网友评论