目录
DockerFile
一、是什么
二、构建步骤
DockerFile构建过程
一、DockerFile基础
二、Docker执行DockerFile的流程
三、总结
DockerFile常用保留字
零、参考Tomcat的DockerFile
一、FROM
二、MAINTAINER
三、RUN
1.shell
2.exec
四、EXPOSE
五、WORKDIR
六、USER
七、ENV
八、ADD
九、COPY
十、VOLUME
十一、CMD
1.举个栗子
2.CMD和RUN之间的区别
十二、ENTRYPOINT
1.举个栗子
2.优点
3.注意
举例
零、需求和准备
一、编写Dockerfile文件
二、构建
UnionFS联合文件系统
DockerFile是用来构建Docker镜像的文本文件,其中包括了一条条构建镜像所需要的指令和参数。
编写DockerFile文件 ---> Docker build构建镜像 ---> Docker run以镜像运行容器实例。
1.每条保留字(至于保留字是什么后面会提)必须为大写字母且后面要跟随至少一个参数
2.指令按照从从上到下,依次执行
3.#表示注释
4.每条指令都会创建一个新的镜像层,并对镜像进行提交
1.docker以基础镜像运行一个容器
#以镜像启动容器,“有了类,才能new一个对象”
2.执行一条指令并对容器做出修改
3.执行类似于Docker commit的操作提交一个新的镜像层
4.Docker再基于刚刚提交的镜像运行一个新的容器
5.执行DockerFile中的下一条指令,直到所有指令执行完成
从应用软件的角度来看,DockerFile、Docker镜像与Docker容器分别代表软件的三个不同阶段,可以看做是它的生命周期。
1.DockerFile是软件的原材料
2.Docker镜像是软件的交付品
3.Docker容器则可以认为是软件镜像的运行态,也即依照镜像运行的容器实例
DockerFile面向开发,Docker镜像成为交付标准,Docker容器则涉及部署与运维,三者缺一不可,合力充当Docker体系的基石。
1 DockerFile,需要定义一个DockerFile,Dockerfile定义了进程需要的一切东西。Dockerfile涉及的内容包括执行代码或者是文件、环境变量、依赖包、运行时环境、动态链接库、操作系统的发行版、服务进程和内核进程(当应用进程需要和系统服务和内核进程打交道,这时需要考虑如何设计namespace的权限控制)等等;
2 Docker镜像,在用Dockerfile定义一个文件之后,docker build时会产生一个Docker镜像,当运行 Docker镜像时会真正开始提供服务;
3 Docker容器,容器是直接提供服务的。
这里去DockerHub中去看看tomcat:Docker Hub
然后随便选一个看看
这里可能有人会连不上GitHub,复制了部分过来。其DockerFile内容如下:
...此处省略...
FROM amazoncorretto:8-al2-jdk
ENV CATALINA_HOME /usr/local/tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
RUN mkdir -p "$CATALINA_HOME"
WORKDIR $CATALINA_HOME
# let "Tomcat Native" live somewhere isolated
ENV TOMCAT_NATIVE_LIBDIR $CATALINA_HOME/native-jni-lib
ENV LD_LIBRARY_PATH ${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOMCAT_NATIVE_LIBDIR
# see https://www.apache.org/dist/tomcat/tomcat-10/KEYS
# see also "versions.sh" (https://github.com/docker-library/tomcat/blob/master/versions.sh)
ENV GPG_KEYS A9C5DF4D22E99998D9875A5110C01C5A2F6059E7
ENV TOMCAT_MAJOR 10
ENV TOMCAT_VERSION 10.0.23
ENV TOMCAT_SHA512 0e0263e8280f2ccfb4bef916444a6105fef689a3d95c334c8a7bfe59f1e3966d48ea624727f1818a4df331a603f1ac5e21b908dda3cae676ddc1aef90c2d12ab
...内容过多,此处省略...
# verify Tomcat Native is working properly
RUN set -eux; \
nativeLines="$(catalina.sh configtest 2>&1)"; \
nativeLines="$(echo "$nativeLines" | grep 'Apache Tomcat Native')"; \
nativeLines="$(echo "$nativeLines" | sort -u)"; \
if ! echo "$nativeLines" | grep -E 'INFO: Loaded( APR based)? Apache Tomcat Native library' >&2; then \
echo >&2 "$nativeLines"; \
exit 1; \
fi
EXPOSE 8080
CMD ["catalina.sh", "run"]
这里官网上标红的部分如FROM ENV RUN WORKDIR EXPOSE CMD这些就是上面提到的保留字,可以看做是命令关键字。例如最后所提到的
EXPOSE 8080
这也就是tomcat所暴露的默认端口8080。在官网How to use this image.这一节中有提到:
运行默认的Tomcat服务,相当于在启动后默认添加一段:
CMD ["catalina.sh", "run"]
这一段就来自于刚刚所看的DockerFile的结尾。
基本上都会出现在DockerFile的第一行。代表你目前的镜像来自于哪,它的基础镜像是什么,有点类似于继承的哪个父类。比如上面看的Tomcat中的第一行:
FROM amazoncorretto:8-al2-jdk
意思为,他的基础镜像是亚马逊...,然后在此基础之上添加了下面的内容。
维护者,用于标注镜像的作者,和TA的联系方式。
容器构建时所需要的命令(也就是说DockerFile变成Docker镜像的build过程中,会读取你DockerFile中用RUN这个关键字所编写的命令),一种是shell一种是exec。
RUN <命令行命令>
<命令行命令>等同于在终端中的shell命令
例子:
当我们要在容器中添加一个vim功能时,要使用到yum。而以下的命令则是告诉你:在基础镜像之上,我们添加了一个安装vim的功能。
RUN yum -y install vim
RUN ["可执行文件","参数1","参数2"]
#RUN ["./123.sh","1","2"] 等价于RUN ./123.sh 1 2
当前容器对外曝露的端口,类似于运行容器时添加的 -p 和 -P 。
在容器创建以后,终端默认登陆进来的工作目录就是一个落脚点。
举例:咱们在容器里运行个Ubuntu看看:
docker run -it ubuntu bash
在运行后紧接着pwd查看一下当先位置:
pwd
可以看到当前在根目录,所以说Ubuntu的默认落脚点为自身的根目录。
咱们换一个看看其它情况(这里故意加了一个bash,以用作演示):
docker run -it -p 8080:8080 tomcat:8 bash
接着pwd:
pwd
可以看到这里的落脚点为 /usr/local/tomcat 。
至于为什么咱们的Ubuntu和tomcat的落脚点会不同,就是因为tomcat的DockerFile中用WORKDIR自己定义了一个落脚点。 在后面的七、ENV那块还会提一嘴。
指定该镜像以什么样的用户去执行,若不指定,则默认为root。
运行时环境。用来在构建镜像过程中设置环境变量。
再来看看之前看tomcat的DockerFile这张图:
比如这里的:
ENV CATALINA_HOME /usr/local/tomcat
格式有点类似于kv键值对,用于定义一个变量并以在后面进行引用。这里的意思是定义了一个CATALINA_HOME变量,它所指的是/usr/local/tomcat的这个路径。图中的:
WORKDIR $CATALINA_HOME
这里是引用了这个CATALINA_HOME变量作为它的落脚点。 也就是上面提到的WORKDIR。这也正是tomcat的落脚点为啥会是/usr/local/tomcat的原因。
将宿主机目录下的文件拷贝到镜像。且会自动处理URL和解压tar压缩包。相当于下面的COPY加上一个解压功能。
拷贝文件和目录到镜像中。类似于docker基础命令中的cp。
COPY ["src","dest"]
#src:源文件或源目录
#dest:容器内指定的路径,若所指定的路径不存在,则会自动创建好。
容器数据卷,相当于运行容器时的 -v 。关于容器数据卷的详解可以查看之间的博客:Docker容器数据卷
指定容器在启动后要进行的操作。CMD和RUN一样,也同样支持 shell 和 exec 格式。
CMD
#shell格式
CMD ["可执行文件","参数1","餐数2"]
#exec格式
CMD ["参数1","餐数2","餐数3"...]
#参数列表格式
这里新提到的 参数列表格式 :当在指定了ENTRYPOINT后,CMD用于指定具体参数。
简单来说也就是在有了ENTRYPOINT之后,CMD就变成用来给它传参的了。
一个DockerFile中可以有多个CMD指令,但是只有最后一个会生效。这里我们来看看tomcat的DockerFile最后两行:
EXPOSE 8080
CMD ["catalina.sh", "run"]
先曝露出8080端口,然后最后一行是一个运行操作。若在后面继续添加一个CMD,则此处的 CMD ["catalina.sh", "run"] 将会直接失效。
docker run -it -p 8080:8080 tomcat:8
这回咱们正常启动,后面没有加之前bash
然后我们去正常访问8080,可以正常看到咱们的猫猫(如果你访问8080报错404可以看看这篇:Docker容器安装Tomcat高版本,解决访问8080报错404):
这里一切都是正常的。然后咱们去搞点事情。
咱们这回在后面给它加上 /bin/bash :
docker run -it -p 8080:8080 tomcat:8 /bin/bash
这就相当于给它的DockerFile多加了一行,变成了以下的样子:
EXPOSE 8080
CMD ["catalina.sh", "run"]
CMD ["/bin/bash","run"]
咱们这时候再去看看8080的猫猫还在不在:
这时候猫猫就不见了(连不上8080)。 这也就是咱们上面提到的:CMD可以允许有多个,但是只有最后一个会正常执行,这里的 CMD ["/bin/bash","run"] 将之前的 CMD ["catalina.sh", "run"] 给覆盖了,所以猫猫不见了。
CMD在docker run时运行
RUN在docker build时运行
同样也是定容器在启动后要进行的操作。与CMD类似,但是ENTRYPOINT不会被docker run后面的命令覆盖,而且这些命令行参数会被当做参数传给ENTRYPOINT指定的程序。
命令格式:
ENTRYPOINT ["<可执行文件>","<参数1>","<参数2>"...]
ENTRYPOINT 可以和 CMD 一起用,这里的 CMD 等于是在给 ENTRYPOINT 传参。
简单来说 ENTRYPOINT 的优先级比 CMD 跟高一些,一起使用时会变成:
""
假设用DockerFile来构建Nginx的镜像:
FROM nginx
ENTRYPOINT ["nginx","-c"]
#定参
CMD ["/etc/nginx/nginx.conf"]
#变参
上述DockerFile衍生出的实际命令如下:
nginx -c /etc/nginx/nginx.conf
那如果在运行时添加了参数,如下:
docker run nginx -c /etc/nginx/new.conf
这里因为在运行时,添加了一个新的conf,也就相当于在DockerFile中添加了一段新的CMD。咱们在上面有提到,CMD会被最后的CMD代替掉(也就是只有最后一个CMD能正常运行),那么以上代码在实际运行时其实如下:
nginx -c /etc/nginx/new.conf
即便在DockerFile中写了 ENTRYPOINT+CMD ,但是还是会被run后面新加的参数代替。
在执行docker run的时候可以给ENTRYPOINT添加所需要的参数
若DockerFile中存在多个ENTRYPOINT,仅最后一个生效
需求:使用DockerFile给CentOS镜像上添加vim+ifconfig+jdk8,启动一下(但是我这里建议各位在拉centos镜像的时候加上版本号7,后面会提到):
docker run -it 5d0da3dc9764 /bin/bash
咱么刚刚拉取下来的Centos镜像是不具备上述功能的,咱们查看一下:
vim 1.txt
ifconfig
java -version
我们现在去下一个jdk的gz包(随便选一个即可,这里我用的是171):jdk镜像下载
在宿主机的根目录下创建一个新目录,叫做myfile然后使用xftp等工具将上面下载的包传进去:
mkdir /myfile
然后在此目录下用vim新建文件Dockerfile,注意:这里的D要大写,f要小写:
vim Dockerfile
注意点:因为CentOS8已经停止维护了,所以这里的第一行FROM后面需要加上7的版本号,否则后面会报错,将以下内容复制进去:
FROM centos:7
#基础镜像
MAINTAINER van<[email protected]>
#维护者和联系方式
ENV MYPATH /usr/local
WORKDIR $MYPATH
#以变量的形式给到一个落脚点
RUN yum -y install vim
#安装vim编辑器
RUN yum -y install net-tools
#安装ifconfig命令查看网络IP
RUN yum -y install glibc.i686
RUN mkdir /usr/local/java
#安装java8及lib库
ADD jdk-8u171-linux-x64.tar.gz /usr/local/java/
#ADD 是相对路径jar,把jdk-8u171-linux-x64.tar.gz添加到容器中,安装包必须要和Dockerfile文件在同一位置
ENV JAVA_HOME /usr/local/java/jdk1.8.0_171
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
ENV PATH $JAVA_HOME/bin:$PATH
#配置java环境变量
EXPOSE 80
#centos也不需要去曝露什么端口,这里是随便写的
CMD echo $MYPATH
CMD echo "success###############ok"
CMD /bin/bash
让在当前目录下进行构建:
docker build -t centosjava8:1.5 .
.号是指镜像构建时打包上传到Docker引擎中的文件的目录,不是本机目录。这里要注意的是:版本号后面有一个空格,之后再加上.
过程可能会比较漫长,运行结果如下:
可以看到,所有的Dockerfile指令都已经构建成功。
咱们docker images查看一下:
docker images
(我这里出现了一个虚悬镜像,留到下一篇博客再讲吧。已经写完了:Docker容器:虚悬镜像) 可以看到新的镜像大小有整整1.22个G比原先的200多M大了不少。运行一下(注意一下自己的镜像ID):
docker run -it 24af206ac896 /bin/bash
pwd查看一下落脚点在哪
pwd
和我们之前设置的WORKDIR落脚点一致,没有问题。
再来看看其它功能是否正常
vim 1.txt
ifconfig
java -version
试验成功!
这里我把整个构建的过程复制过来:
[root@vanqiyeah myfile]# docker build -t centosjava8:1.5 .
Sending build context to Docker daemon 190.9MB
Step 1/17 : FROM centos:7
7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987
Status: Downloaded newer image for centos:7
---> eeb6ee3f44bd
Step 2/17 : MAINTAINER van<[email protected]>
---> Running in bedec783f19e
Removing intermediate container bedec783f19e
---> 3d5b6d941195
Step 3/17 : ENV MYPATH /usr/local
---> Running in f08acf892bbe
Removing intermediate container f08acf892bbe
---> d892076f0380
Step 4/17 : WORKDIR $MYPATH
---> Running in da6bfab459dc
Removing intermediate container da6bfab459dc
---> a9b042242153
Step 5/17 : RUN yum -y install vim
---> Running in 1f31b178d7b0
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
* base: mirrors.cn99.com
* extras: mirrors.nju.edu.cn
* updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be installed
--> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Processing Dependency: which for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Running transaction check
---> Package gpm-libs.x86_64 0:1.20.7-6.el7 will be installed
---> Package perl.x86_64 4:5.16.3-299.el7_9 will be installed
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-299.el7_9.x86_64
---> Package perl-libs.x86_64 4:5.16.3-299.el7_9 will be installed
---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be installed
--> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.629-8.el7_9.x86_64
---> Package which.x86_64 0:2.20-7.el7 will be installed
--> Running transaction check
---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
---> Package perl-Socket.x86_64 0:2.010-5.el7 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-macros.x86_64 4:5.16.3-299.el7_9 will be installed
---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
---> Package vim-filesystem.x86_64 2:7.4.629-8.el7_9 will be installed
--> Running transaction check
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-299.el7_9 will be installed
---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
--> Running transaction check
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: groff-base for package: perl-Pod-Perldoc-3.20-4.el7.noarch
---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
--> Running transaction check
---> Package groff-base.x86_64 0:1.22.2-8.el7 will be installed
---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
vim-enhanced x86_64 2:7.4.629-8.el7_9 updates 1.1 M
Installing for dependencies:
gpm-libs x86_64 1.20.7-6.el7 base 32 k
groff-base x86_64 1.22.2-8.el7 base 942 k
perl x86_64 4:5.16.3-299.el7_9 updates 8.0 M
perl-Carp noarch 1.26-244.el7 base 19 k
perl-Encode x86_64 2.51-7.el7 base 1.5 M
perl-Exporter noarch 5.68-3.el7 base 28 k
perl-File-Path noarch 2.09-2.el7 base 26 k
perl-File-Temp noarch 0.23.01-3.el7 base 56 k
perl-Filter x86_64 1.49-3.el7 base 76 k
perl-Getopt-Long noarch 2.40-3.el7 base 56 k
perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k
perl-PathTools x86_64 3.40-5.el7 base 82 k
perl-Pod-Escapes noarch 1:1.04-299.el7_9 updates 52 k
perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k
perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k
perl-Pod-Usage noarch 1.63-3.el7 base 27 k
perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k
perl-Socket x86_64 2.010-5.el7 base 49 k
perl-Storable x86_64 2.45-3.el7 base 77 k
perl-Text-ParseWords noarch 3.29-4.el7 base 14 k
perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k
perl-Time-Local noarch 1.2300-2.el7 base 24 k
perl-constant noarch 1.27-2.el7 base 19 k
perl-libs x86_64 4:5.16.3-299.el7_9 updates 690 k
perl-macros x86_64 4:5.16.3-299.el7_9 updates 44 k
perl-parent noarch 1:0.225-244.el7 base 12 k
perl-podlators noarch 2.5.1-3.el7 base 112 k
perl-threads x86_64 1.87-4.el7 base 49 k
perl-threads-shared x86_64 1.43-6.el7 base 39 k
vim-common x86_64 2:7.4.629-8.el7_9 updates 5.9 M
vim-filesystem x86_64 2:7.4.629-8.el7_9 updates 11 k
which x86_64 2.20-7.el7 base 41 k
Transaction Summary
================================================================================
Install 1 Package (+32 Dependent packages)
Total download size: 19 M
Installed size: 63 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/gpm-libs-1.20.7-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for gpm-libs-1.20.7-6.el7.x86_64.rpm is not installed
Public key for perl-Pod-Escapes-1.04-299.el7_9.noarch.rpm is not installed
--------------------------------------------------------------------------------
Total 1.1 MB/s | 19 MB 00:16
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) "
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-9.2009.0.el7.centos.x86_64 (@CentOS)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gpm-libs-1.20.7-6.el7.x86_64 1/33
Installing : 2:vim-filesystem-7.4.629-8.el7_9.x86_64 2/33
Installing : 2:vim-common-7.4.629-8.el7_9.x86_64 3/33
Installing : which-2.20-7.el7.x86_64 4/33
install-info: No such file or directory for /usr/share/info/which.info.gz
Installing : groff-base-1.22.2-8.el7.x86_64 5/33
Installing : 1:perl-parent-0.225-244.el7.noarch 6/33
Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 7/33
Installing : perl-podlators-2.5.1-3.el7.noarch 8/33
Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 9/33
Installing : 1:perl-Pod-Escapes-1.04-299.el7_9.noarch 10/33
Installing : perl-Encode-2.51-7.el7.x86_64 11/33
Installing : perl-Text-ParseWords-3.29-4.el7.noarch 12/33
Installing : perl-Pod-Usage-1.63-3.el7.noarch 13/33
Installing : 4:perl-macros-5.16.3-299.el7_9.x86_64 14/33
Installing : perl-Storable-2.45-3.el7.x86_64 15/33
Installing : perl-Exporter-5.68-3.el7.noarch 16/33
Installing : perl-constant-1.27-2.el7.noarch 17/33
Installing : perl-Socket-2.010-5.el7.x86_64 18/33
Installing : perl-Time-Local-1.2300-2.el7.noarch 19/33
Installing : perl-Carp-1.26-244.el7.noarch 20/33
Installing : perl-PathTools-3.40-5.el7.x86_64 21/33
Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 22/33
Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 23/33
Installing : perl-File-Temp-0.23.01-3.el7.noarch 24/33
Installing : perl-File-Path-2.09-2.el7.noarch 25/33
Installing : perl-threads-shared-1.43-6.el7.x86_64 26/33
Installing : perl-threads-1.87-4.el7.x86_64 27/33
Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 28/33
Installing : perl-Filter-1.49-3.el7.x86_64 29/33
Installing : 4:perl-libs-5.16.3-299.el7_9.x86_64 30/33
Installing : perl-Getopt-Long-2.40-3.el7.noarch 31/33
Installing : 4:perl-5.16.3-299.el7_9.x86_64 32/33
Installing : 2:vim-enhanced-7.4.629-8.el7_9.x86_64 33/33
Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/33
Verifying : perl-threads-shared-1.43-6.el7.x86_64 2/33
Verifying : perl-Storable-2.45-3.el7.x86_64 3/33
Verifying : groff-base-1.22.2-8.el7.x86_64 4/33
Verifying : perl-Exporter-5.68-3.el7.noarch 5/33
Verifying : perl-constant-1.27-2.el7.noarch 6/33
Verifying : perl-PathTools-3.40-5.el7.x86_64 7/33
Verifying : 4:perl-macros-5.16.3-299.el7_9.x86_64 8/33
Verifying : 2:vim-enhanced-7.4.629-8.el7_9.x86_64 9/33
Verifying : 1:perl-parent-0.225-244.el7.noarch 10/33
Verifying : perl-Socket-2.010-5.el7.x86_64 11/33
Verifying : which-2.20-7.el7.x86_64 12/33
Verifying : 2:vim-filesystem-7.4.629-8.el7_9.x86_64 13/33
Verifying : perl-File-Temp-0.23.01-3.el7.noarch 14/33
Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 15/33
Verifying : perl-Time-Local-1.2300-2.el7.noarch 16/33
Verifying : 1:perl-Pod-Escapes-1.04-299.el7_9.noarch 17/33
Verifying : perl-Carp-1.26-244.el7.noarch 18/33
Verifying : 2:vim-common-7.4.629-8.el7_9.x86_64 19/33
Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 20/33
Verifying : perl-Pod-Usage-1.63-3.el7.noarch 21/33
Verifying : perl-Encode-2.51-7.el7.x86_64 22/33
Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 23/33
Verifying : perl-podlators-2.5.1-3.el7.noarch 24/33
Verifying : 4:perl-5.16.3-299.el7_9.x86_64 25/33
Verifying : perl-File-Path-2.09-2.el7.noarch 26/33
Verifying : perl-threads-1.87-4.el7.x86_64 27/33
Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 28/33
Verifying : gpm-libs-1.20.7-6.el7.x86_64 29/33
Verifying : perl-Filter-1.49-3.el7.x86_64 30/33
Verifying : perl-Getopt-Long-2.40-3.el7.noarch 31/33
Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 32/33
Verifying : 4:perl-libs-5.16.3-299.el7_9.x86_64 33/33
Installed:
vim-enhanced.x86_64 2:7.4.629-8.el7_9
Dependency Installed:
gpm-libs.x86_64 0:1.20.7-6.el7
groff-base.x86_64 0:1.22.2-8.el7
perl.x86_64 4:5.16.3-299.el7_9
perl-Carp.noarch 0:1.26-244.el7
perl-Encode.x86_64 0:2.51-7.el7
perl-Exporter.noarch 0:5.68-3.el7
perl-File-Path.noarch 0:2.09-2.el7
perl-File-Temp.noarch 0:0.23.01-3.el7
perl-Filter.x86_64 0:1.49-3.el7
perl-Getopt-Long.noarch 0:2.40-3.el7
perl-HTTP-Tiny.noarch 0:0.033-3.el7
perl-PathTools.x86_64 0:3.40-5.el7
perl-Pod-Escapes.noarch 1:1.04-299.el7_9
perl-Pod-Perldoc.noarch 0:3.20-4.el7
perl-Pod-Simple.noarch 1:3.28-4.el7
perl-Pod-Usage.noarch 0:1.63-3.el7
perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
perl-Socket.x86_64 0:2.010-5.el7
perl-Storable.x86_64 0:2.45-3.el7
perl-Text-ParseWords.noarch 0:3.29-4.el7
perl-Time-HiRes.x86_64 4:1.9725-3.el7
perl-Time-Local.noarch 0:1.2300-2.el7
perl-constant.noarch 0:1.27-2.el7
perl-libs.x86_64 4:5.16.3-299.el7_9
perl-macros.x86_64 4:5.16.3-299.el7_9
perl-parent.noarch 1:0.225-244.el7
perl-podlators.noarch 0:2.5.1-3.el7
perl-threads.x86_64 0:1.87-4.el7
perl-threads-shared.x86_64 0:1.43-6.el7
vim-common.x86_64 2:7.4.629-8.el7_9
vim-filesystem.x86_64 2:7.4.629-8.el7_9
which.x86_64 0:2.20-7.el7
Complete!
Removing intermediate container 1f31b178d7b0
---> 636ad52d5f4e
Step 6/17 : RUN yum -y install net-tools
---> Running in 231811e49297
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.nju.edu.cn
* updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
net-tools x86_64 2.0-0.25.20131004git.el7 base 306 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 306 k
Installed size: 917 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
Verifying : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
Installed:
net-tools.x86_64 0:2.0-0.25.20131004git.el7
Complete!
Removing intermediate container 231811e49297
---> e7d6bb4a5865
Step 7/17 : RUN yum -y install glibc.i686
---> Running in 7d5529db79c6
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.nju.edu.cn
* updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package glibc.i686 0:2.17-326.el7_9 will be installed
--> Processing Dependency: glibc-common = 2.17-326.el7_9 for package: glibc-2.17-326.el7_9.i686
--> Processing Dependency: libfreebl3.so(NSSRAWHASH_3.12.3) for package: glibc-2.17-326.el7_9.i686
--> Processing Dependency: libfreebl3.so for package: glibc-2.17-326.el7_9.i686
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-317.el7 will be updated
--> Processing Dependency: glibc-common = 2.17-317.el7 for package: glibc-2.17-317.el7.x86_64
---> Package glibc-common.x86_64 0:2.17-326.el7_9 will be an update
---> Package nss-softokn-freebl.x86_64 0:3.53.1-6.el7_9 will be updated
---> Package nss-softokn-freebl.i686 0:3.67.0-3.el7_9 will be installed
--> Processing Dependency: nss-util >= 3.67.0-1 for package: nss-softokn-freebl-3.67.0-3.el7_9.i686
--> Processing Dependency: nspr >= 4.30.0 for package: nss-softokn-freebl-3.67.0-3.el7_9.i686
---> Package nss-softokn-freebl.x86_64 0:3.67.0-3.el7_9 will be an update
--> Running transaction check
---> Package glibc.x86_64 0:2.17-317.el7 will be updated
---> Package glibc.x86_64 0:2.17-326.el7_9 will be an update
---> Package nspr.x86_64 0:4.25.0-2.el7_9 will be updated
---> Package nspr.x86_64 0:4.32.0-1.el7_9 will be an update
---> Package nss-util.x86_64 0:3.53.1-1.el7_9 will be updated
---> Package nss-util.x86_64 0:3.67.0-1.el7_9 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
glibc i686 2.17-326.el7_9 updates 4.3 M
Installing for dependencies:
nss-softokn-freebl i686 3.67.0-3.el7_9 updates 325 k
Updating for dependencies:
glibc x86_64 2.17-326.el7_9 updates 3.6 M
glibc-common x86_64 2.17-326.el7_9 updates 12 M
nspr x86_64 4.32.0-1.el7_9 updates 127 k
nss-softokn-freebl x86_64 3.67.0-3.el7_9 updates 337 k
nss-util x86_64 3.67.0-1.el7_9 updates 79 k
Transaction Summary
================================================================================
Install 1 Package (+1 Dependent package)
Upgrade ( 5 Dependent packages)
Total download size: 20 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
--------------------------------------------------------------------------------
Total 35 kB/s | 20 MB 09:45
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : nss-softokn-freebl-3.67.0-3.el7_9.x86_64 1/12
Updating : glibc-common-2.17-326.el7_9.x86_64 2/12
Updating : glibc-2.17-326.el7_9.x86_64 3/12
Updating : nspr-4.32.0-1.el7_9.x86_64 4/12
Updating : nss-util-3.67.0-1.el7_9.x86_64 5/12
Installing : nss-softokn-freebl-3.67.0-3.el7_9.i686 6/12
Installing : glibc-2.17-326.el7_9.i686 7/12
Cleanup : nspr-4.25.0-2.el7_9.x86_64 8/12
Cleanup : nss-util-3.53.1-1.el7_9.x86_64 9/12
Cleanup : nss-softokn-freebl-3.53.1-6.el7_9.x86_64 10/12
Cleanup : glibc-common-2.17-317.el7.x86_64 11/12
Cleanup : glibc-2.17-317.el7.x86_64 12/12
Verifying : glibc-common-2.17-326.el7_9.x86_64 1/12
Verifying : nss-softokn-freebl-3.67.0-3.el7_9.x86_64 2/12
Verifying : glibc-2.17-326.el7_9.x86_64 3/12
Verifying : nss-util-3.67.0-1.el7_9.x86_64 4/12
Verifying : nspr-4.32.0-1.el7_9.x86_64 5/12
Verifying : glibc-2.17-326.el7_9.i686 6/12
Verifying : nss-softokn-freebl-3.67.0-3.el7_9.i686 7/12
Verifying : glibc-2.17-317.el7.x86_64 8/12
Verifying : glibc-common-2.17-317.el7.x86_64 9/12
Verifying : nspr-4.25.0-2.el7_9.x86_64 10/12
Verifying : nss-softokn-freebl-3.53.1-6.el7_9.x86_64 11/12
Verifying : nss-util-3.53.1-1.el7_9.x86_64 12/12
Installed:
glibc.i686 0:2.17-326.el7_9
Dependency Installed:
nss-softokn-freebl.i686 0:3.67.0-3.el7_9
Dependency Updated:
glibc.x86_64 0:2.17-326.el7_9 glibc-common.x86_64 0:2.17-326.el7_9
nspr.x86_64 0:4.32.0-1.el7_9 nss-softokn-freebl.x86_64 0:3.67.0-3.el7_9
nss-util.x86_64 0:3.67.0-1.el7_9
Complete!
Removing intermediate container 7d5529db79c6
---> 12d42a5b6004
Step 8/17 : RUN mkdir /usr/local/java
---> Running in 3e8a6abff8e2
Removing intermediate container 3e8a6abff8e2
---> f4c3fd2bae1f
Step 9/17 : ADD jdk-8u171-linux-x64.tar.gz /usr/local/java/
---> 440a6bd6da61
Step 10/17 : ENV JAVA_HOME /usr/local/java/jdk1.8.0_171
---> Running in 24bc3cb8bd04
Removing intermediate container 24bc3cb8bd04
---> 13c4ca55f35e
Step 11/17 : ENV JRE_HOME $JAVA_HOME/jre
---> Running in 782b9bbf4d78
Removing intermediate container 782b9bbf4d78
---> f9051f305225
Step 12/17 : ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
---> Running in 937c1030ddd1
Removing intermediate container 937c1030ddd1
---> d9d89b3a80e0
Step 13/17 : ENV PATH $JAVA_HOME/bin:$PATH
---> Running in 92d4091fcb25
Removing intermediate container 92d4091fcb25
---> 3e3fe4a7e8ee
Step 14/17 : EXPOSE 80
---> Running in 3478980aa8b5
Removing intermediate container 3478980aa8b5
---> 370ac0bf88e2
Step 15/17 : CMD echo $MYPATH
---> Running in eeb80d74b277
Removing intermediate container eeb80d74b277
---> 7c81a14e5fff
Step 16/17 : CMD echo "success###############ok"
---> Running in bfb99fd052de
Removing intermediate container bfb99fd052de
---> 94dc9fe4a32f
Step 17/17 : CMD /bin/bash
---> Running in f5e3b73e37ec
Removing intermediate container f5e3b73e37ec
---> 24af206ac896
Successfully built 24af206ac896
Successfully tagged centosjava8:1.5
UnionFS(联合文件系统):Union文件系统(UnionFS)是一种分层、轻量级并且高性能的文件系统,它支持对文件系统的修改作为一次提交来一层层的叠加,同时可以将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtual filesystem)。Union 文件系统是 Docker 镜像的基础。镜像可以通过分层来进行继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。
回头看看构建过程中的17个步骤, 再自行体会一下什么是联合文件系统。