Dockerfile:镜像制作方式
Docker Images制作2种方式:
docker commit
Dockerfile:文本文件,镜像文件构建脚本;
Dockerfile:由一系列用于根据基础镜像构建新的镜像文件的专用指令序列组成;
指令:选定基础镜像、安装必要的程序、复制配置文件和数据文件、自动运行的服务以及要暴露的端口等;
命令:docker build;
语法:指令行、注释行和空白行;
指令行:由指令及指令参数构成;
指令:其字符不区分大小写;约定俗成,要使用全大写字符;
注释行:#开头的行,必须单独位于一行当中;
空白行:会被忽略;
指令:
FROM指令:
FROM指令是最重的一个且必须为Dockerfile文件开篇的第一个非 注释行,用于为映像文件构建过程指定基准镜像,后续的指令运 行于此基准镜像所提供的运行环境
实践中,基准镜像可以是任何可用镜像文件,默认情况下,docker build会在docker主机上查找指定的镜像文件,在其不存在时,则会从Docker Hub Registry上拉取所需的镜像文件
如果找不到指定的镜像文件,docker build会返回一个错误信
语法格式:
FROM <image>[:<tag>] 或
FROM <image>@<digest>
<image>:指定作为base image的名称;
<tag>:base image的标签,为可选项,省略时默认为latest
FROM busybox:latest
FROM centos:6.9
注意:尽量不要在一个dockerfile文件中使用多个FROM指令;
MAINTANIER指令:用于提供信息的指令,用于让作者提供本人的信息;不限制其出现的位置,但建议紧跟在FROM之后;
语法格式:
MAINTANIER <author's detail>
例如:
MAINTANIER MageEdu Linux Operation and Maintance Institute <mage@magedu.com>
COPY指令:用于从docker主机复制文件至正在创建的新映像文件中;
语法格式:
COPY <src> ... <dest>
COPY ["<src>",... "<dest>"] (文件名中有空白字符时使用此种格式)
<src>:要复制的源文件或目录,支持使用通配符;
<dest>:目标路径,正在创建的镜像文件的文件系统路径;建立使用绝对路径,否则,则相对于WORKDIR而言;
所有新复制生成的目录文件的UID和GID均为0;
例如:
COPY server.xml /etc/tomcat/server.xml
COPY *.conf /etc/httpd/conf.d/
注意:
<src>必须是build上下文中的路径,因此,不能使用类似“../some_dir/some_file”类的路径;
<src>如果是目录,递归复制会自动行;如果有多个<src>,包括在<src>上使用了通配符这种情形,此时<dest>必须是目录,而且必须得以/结尾;
<dest>如果事先不存在,它将被自动创建,包括其父目录;
[root@node5 ~]# mkdir busybox/
[root@node5 ~]# cd busybox/
[root@node5 busybox]# ls
[root@node5 busybox]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/wangjinhuai/busybox v0.1.1 913da7e1ffaa 46 hours ago 1.15 MB
docker.io/centos/nginx v0.1.0 3c6bc6ca3188 47 hours ago 314 MB
docker.io/container/httpd v0.1.0 7bfc3c50a470 47 hours ago 305 MB
docker.io/centos latest 1e1148e4cc2c 2 weeks ago 202 MB
docker.io/busybox latest 59788edf1f3e 2 months ago 1.15 MB
docker.io/wangjinhuai/busybox v0.1.0 59788edf1f3e 2 months ago 1.15 MB
[root@node5 busybox]# vi Dockerfile
FROM busybox:latest
MAINTAINER "magedu<magedu@magedu>"
COPY index.html /data/html/
[root@node5 busybox]# docker build ./
Sending build context to Docker daemon 3.072 kB
Step 1/3 : FROM busybox:latest
---> 59788edf1f3e
Step 2/3 : MAINTAINER "magedu<magedu@magedu>"
---> Running in 857da643a937
---> f7b6298f5e27
Removing intermediate container 857da643a937
Step 3/3 : COPY index.html /data/html/
---> 83021ac60b38
Removing intermediate container 332507d16dd4
Successfully built 83021ac60b38
[root@node5 busybox]# dokcer images
-bash: dokcer: command not found
[root@node5 busybox]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 83021ac60b38 About a minute ago 1.15 MB
root@node5 busybox]# docker tag 83021ac60b38 docker.io/wangjinhuai/busybox:v0.1.1
[root@node5 busybox]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/wangjinhuai/busybox v0.1.1 83021ac60b38 3 minutes ago 1.15 MB
[root@node5 busybox]# docker tag 83021ac60b38 docker.io/busybox:latest
[root@node5 busybox]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/busybox latest 83021ac60b38 5 minutes ago 1.15 MB
docker.io/wangjinhuai/busybox v0.1.1 83021ac60b38 5 minutes ago 1.15 MB
[root@node5 busybox]# docker run --name test --rm -it docker.io/busybox:latest
/ # ls
bin data dev etc home proc root run sys tmp usr var
/ # cat /data/html/index.html
<h1>Busybox httpd server</h1>
/ # exit
VOLUME指令:用于目标镜像文件中创建一个挂载点目录,用于挂载主机上的卷或其它容器的卷;
语法格式:
VOLUME <mountpoint>
VOLUME ["<mountpoint>", ...]
注意:
如果mountpoint路径下事先有文件存在,docker run命令会在卷挂载完成后将此前的文件复制到新挂载的卷中;
[root@node5 busybox]# vi Dockerfile
FROM busybox:latest
MAINTAINER "megedu <mage@magedu.com>"
COPY data /data/
VOLUME /data/html
[root@node5 busybox]# docker build ./
Sending build context to Docker daemon 3.072 kB
Step 1/4 : FROM busybox:latest
---> 83021ac60b38
Step 2/4 : MAINTAINER "magedu<magedu@magedu>"
---> Using cache
---> 69717ee5ec56
Step 3/4 : COPY index.html /data/html/
---> Using cache
---> 90b20ff0f405
Step 4/4 : VOLUME /data/html
---> Running in 0e8e9749bd29
---> 3c2eec266ae1
Removing intermediate container 0e8e9749bd29
Successfully built 3c2eec266ae1
[root@node5 busybox]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 3c2eec266ae1 9 seconds ago 1.15 MB
[root@node5 busybox]# docker run --name test --rm -it 3c2eec266ae1
/ # ls /data/html/
index.html
/ #exit
[root@node5 ~]# docker inspect test
"Mounts": [
{
"Type": "volume",
"Name": "2148c86bfbdb187ae267e8f4902db5115b7a1e75ce6b4140837f7bd94cb21279",
"Source": "/var/lib/docker/volumes/2148c86bfbdb187ae267e8f4902db5115b7a1e75ce6b4140837f7bd94cb21279/_data",
"Destination": "/data/html",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
[root@node5 ~]# cd /var/lib/docker/volumes/2148c86bfbdb187ae267e8f4902db5115b7a1e75ce6b4140837f7bd94cb21279/_data
[root@node5 _data]# ls
index.html
[root@node5 _data]#
[root@node5 _data]# cat index.html
<h1>Busybox httpd server</h1>
[root@node5 _data]#
ADD指令:类似于COPY指令,额外还支持复制TAR文件,以及URL路径;
语法格式:
ADD <src> ... <dest>
ADD ["<src>",... "<dest>"]
示例:
ADD haproxy.cfg /etc/haproxy/haproxy.cfg
ADD logstash_*.cnf /etc/logstash/
ADD http://www.magedu.com/download/nginx/conf/nginx.conf /etc/nginx/
注意:以URL格式指定的源文件,下载完成后其目标文件的权限为600;
注意:
<src>必须是build上下文中的路径,因此,不能使用类似“../some_dir/some_file”类的路径;
如果<src>是URL,且<dest>不以/结尾,则<src>指定的文件将被下载并直接被创建为<dest>;如果<dest>以/结尾,则URL指定的文件将被下载至<dest>中,并保留原名;
如果<src>是一个host本地的文件系统上的tar格式的文件,它将被展开为一个目录,其行为类似于tar -x命令;但是,如果通过URL下载到的文件是tar格式的,是不会自动进行展开操作的;
<src>如果是目录,递归复制会自动行;如果有多个<src>,包括在<src>上使用了通配符这种情形,此时<dest>必须是目录,而且必须得以/结尾;
<dest>如果事先不存在,它将被自动创建,包括其父目录;
[root@node5 busybox]# vi Dockerfile
FROM busybox:latest
MAINTAINER "magedu<magedu@magedu>"
COPY index.html /data/html/
VOLUME /data/html
ADD http://192.168.170.8/ks.cfg /etc/yum.repos.d/
EXPOSE 11211/tcp
RUN /bin/adduser -D myuser && \
/bin/mkdir /tmp/testdir
[root@node5 busybox]# docker build ./
Sending build context to Docker daemon 3.072 kB
Step 1/7 : FROM busybox:latest
---> 83021ac60b38
Step 2/7 : MAINTAINER "magedu<magedu@magedu>"
---> Using cache
---> 69717ee5ec56
Step 3/7 : COPY index.html /data/html/
---> Using cache
---> 90b20ff0f405
Step 4/7 : VOLUME /data/html
---> Using cache
---> 3c2eec266ae1
Step 5/7 : ADD http://192.168.170.8/ks.cfg /etc/yum.repos.d/
Downloading [==================================================>] 1.564 kB/1.564 kB
---> 56555026b2dc
Removing intermediate container cbd41a345309
Step 6/7 : EXPOSE 11211/tcp
---> Running in 8fcef4565694
---> f1f2ee433fc1
Removing intermediate container 8fcef4565694
Step 7/7 : RUN /bin/adduser -D myuser && /bin/mkdir /tmp/testdir
---> Running in 846d41d7cebd
---> d7bbb2e34bb7
Removing intermediate container 846d41d7cebd
Successfully built d7bbb2e34bb7
[root@node5 busybox]# docker run --name test --rm -it -P d7bbb2e34bb7
/ # ls /etc/yum.repos.d/
ks.cfg
EXPOSE指令:用于为容器指定要暴露的端口;
语法格式:
EXPOSE <port>[/<protocol>] [<port>[/<protocol>]] ...
<protocol>为tcp或udp二者之一,默认为tcp;
例如:EXPOSE 11211/tcp 11211/udp
[root@node5 busybox]# vi Dockerfile
FROM busybox:latest
MAINTAINER "magedu<magedu@magedu>"
COPY index.html /data/html/
VOLUME /data/html
EXPOSE 11211/tcp
[root@node5 busybox]# docker build ./
Sending build context to Docker daemon 3.072 kB
Step 1/5 : FROM busybox:latest
---> 83021ac60b38
Step 2/5 : MAINTAINER "magedu<magedu@magedu>"
---> Using cache
---> 69717ee5ec56
Step 3/5 : COPY index.html /data/html/
---> Using cache
---> 90b20ff0f405
Step 4/5 : VOLUME /data/html
---> Using cache
---> 3c2eec266ae1
Step 5/5 : EXPOSE 11211/tcp
---> Running in 58477c4c7997
---> a1a8f42d29d2
Removing intermediate container 58477c4c7997
Successfully built a1a8f42d29d2
[root@node5 busybox]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> a1a8f42d29d2 16 seconds ago 1.15 MB
[root@node5 busybox]# docker run --name test --rm -it -P a1a8f42d29d2
/ #
[root@node5 ~]# docker port test
11211/tcp -> 0.0.0.0:32770
ENV指令:定义环境变量,此些变量可被当前dockerfile文件中的其它指令所调用,调用格式为$variable_name或${variable_name};
语法:
ENV <key> <value> 一次定义一个变量
ENV <key>=<value> ... 一次可定义多个变量 ,如果<value>中有空白字符,要使用\字符进行转义或加引号;
例如:
ENV myName="Obama Clark" myDog=Hello\ Dog \
myCat=Garfield
等同于:
ENV myName Obama Clark
ENV myDog Hello Dog
ENV myCat Garfield
[root@node5 busybox]# vi Dockerfile
FROM busybox:latest
MAINTAINER "magedu<magedu@magedu>"
COPY index.html /data/html/
VOLUME /data/html
#ADD http://192.168.170.8/ks.cfg /etc/yum.repos.d/
EXPOSE 11211/tcp
ENV epel_repo_file http://192.168.170.8/ks.cfg
ADD ${epel_repo_file} /etc/yum.repos.d/
[root@node5 busybox]# docker build ./
Sending build context to Docker daemon 3.072 kB
Step 1/8 : FROM busybox:latest
---> 83021ac60b38
Step 2/8 : MAINTAINER "magedu<magedu@magedu>"
---> Using cache
---> 69717ee5ec56
Step 3/8 : COPY index.html /data/html/
---> Using cache
---> 90b20ff0f405
Step 4/8 : VOLUME /data/html
---> Using cache
---> 3c2eec266ae1
Step 5/8 : EXPOSE 11211/tcp
---> Using cache
---> a1a8f42d29d2
Step 6/8 : ENV epel_repo_file http://192.168.170.8/ks.cfg
---> Running in 878ce76359a3
---> 60d3af919ef1
Removing intermediate container 878ce76359a3
Step 7/8 : ADD ${epel_repo_file} /etc/yum.repos.d/
Downloading [==================================================>] 1.564 kB/1.564 kB
---> 414bd337ba97
Removing intermediate container 9816345ece4e
Step 8/8 : RUN /bin/adduser -D myuser && /bin/mkdir /tmp/testdir
---> Running in 531212165ac9
---> 634ef003899d
Removing intermediate container 531212165ac9
Successfully built 634ef003899d
[root@node5 busybox]# docker run --name test --rm -it -P 634ef003899d
/ # ls /etc/yum.repos.d/
ks.cfg
/ #
RUN指令:用于指定docker build过程中要运行的命令,而不是docker run此dockerfile构建成的镜像时运行;
语法格式:
RUN <command> 或
RUN ["<executeable>", "<param1>", "<param2>", ...]
RUN ["/bin/bash", "-c", "<executeable>", "<param1>", "<param2>", ...]
例如:
RUN yum install iproute nginx && yum clean all
[root@node5 busybox]# vi Dockerfile
FROM busybox:latest
MAINTAINER "magedu<magedu@magedu>"
COPY index.html /data/html/
VOLUME /data/html
EXPOSE 11211/tcp
RUN /bin/adduser -D myuser && \
/bin/mkdir /tmp/testdir
[root@node5 busybox]# docker build ./
Sending build context to Docker daemon 3.072 kB
Step 1/6 : FROM busybox:latest
---> 83021ac60b38
Step 2/6 : MAINTAINER "magedu<magedu@magedu>"
---> Using cache
---> 69717ee5ec56
Step 3/6 : COPY index.html /data/html/
---> Using cache
---> 90b20ff0f405
Step 4/6 : VOLUME /data/html
---> Using cache
---> 3c2eec266ae1
Step 5/6 : EXPOSE 11211/tcp
---> Using cache
---> a1a8f42d29d2
Step 6/6 : RUN /bin/adduser -D myuser && /bin/mkdir /tmp/testdir
---> Running in 70891c02cbc4
---> 7ee65a5ce5c3
Removing intermediate container 70891c02cbc4
Successfully built 7ee65a5ce5c3
[root@node5 busybox]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 7ee65a5ce5c3 9 seconds ago 1.16 MB
[root@node5 busybox]# docker run --name test --rm -it -P 7ee65a5ce5c3
/ # ls /tmp/
testdir
示例2:
[root@node5 ~]# mkdir nginx
[root@node5 ~]# cd nginx/
[root@node5 nginx]# vi index.html
<h1>Nginx Server Test Home Page </h1>
~
[root@node5 nginx]# vi Dockerfile
FROM centos:latest
MAINTAINER "magedu<magedu@magedu>"
RUN yum -y install epel-release && yum -y install nginx
ADD index.html usr/share/nginx/html/
[root@node5 nginx]# docker build ./
Sending build context to Docker daemon 3.072 kB
Step 1/4 : FROM centos:latest
---> 1e1148e4cc2c
Step 2/4 : MAINTAINER "magedu<magedu@magedu>"
---> Running in 8d47dd9da279
---> 09e2d7ee7439
Removing intermediate container 8d47dd9da279
Step 3/4 : RUN yum -y install epel-release && yum -y install nginx
---> Running in 62c192226b85
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
* base: mirrors.cn99.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 15 k
Installed size: 24 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for epel-release-7-11.noarch.rpm is not installed
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) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-6.1810.2.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 : epel-release-7-11.noarch 1/1
Verifying : epel-release-7-11.noarch 1/1
Installed:
epel-release.noarch 0:7-11
Complete!
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.12.2-2.el7 will be installed
--> Processing Dependency: nginx-filesystem = 1:1.12.2-2.el7 for package: 1:nginx-1.12.2-2.el7.x86_64
--> Processing Dependency: nginx-all-modules = 1:1.12.2-2.el7 for package: 1:nginx-1.12.2-2.el7.x86_64
--> Processing Dependency: openssl for package: 1:nginx-1.12.2-2.el7.x86_64
--> Processing Dependency: nginx-filesystem for package: 1:nginx-1.12.2-2.el7.x86_64
--> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.12.2-2.el7.x86_64
--> Running transaction check
---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed
---> Package nginx-all-modules.noarch 1:1.12.2-2.el7 will be installed
--> Processing Dependency: nginx-mod-stream = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch
--> Processing Dependency: nginx-mod-mail = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch
--> Processing Dependency: nginx-mod-http-xslt-filter = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch
--> Processing Dependency: nginx-mod-http-perl = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch
--> Processing Dependency: nginx-mod-http-image-filter = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch
--> Processing Dependency: nginx-mod-http-geoip = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch
---> Package nginx-filesystem.noarch 1:1.12.2-2.el7 will be installed
---> Package openssl.x86_64 1:1.0.2k-16.el7 will be installed
--> Processing Dependency: make for package: 1:openssl-1.0.2k-16.el7.x86_64
--> Running transaction check
---> Package make.x86_64 1:3.82-23.el7 will be installed
---> Package nginx-mod-http-geoip.x86_64 1:1.12.2-2.el7 will be installed
--> Processing Dependency: GeoIP for package: 1:nginx-mod-http-geoip-1.12.2-2.el7.x86_64
--> Processing Dependency: libGeoIP.so.1()(64bit) for package: 1:nginx-mod-http-geoip-1.12.2-2.el7.x86_64
---> Package nginx-mod-http-image-filter.x86_64 1:1.12.2-2.el7 will be installed
--> Processing Dependency: gd for package: 1:nginx-mod-http-image-filter-1.12.2-2.el7.x86_64
--> Processing Dependency: libgd.so.2()(64bit) for package: 1:nginx-mod-http-image-filter-1.12.2-2.el7.x86_64
---> Package nginx-mod-http-perl.x86_64 1:1.12.2-2.el7 will be installed
--> Processing Dependency: perl >= 5.006001 for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64
--> Processing Dependency: perl(warnings) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64
--> Processing Dependency: perl(strict) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64
--> Processing Dependency: perl(constant) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64
--> Processing Dependency: perl(XSLoader) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64
--> Processing Dependency: perl(Exporter) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64
--> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64
---> Package nginx-mod-http-xslt-filter.x86_64 1:1.12.2-2.el7 will be installed
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64
--> Processing Dependency: libxslt.so.1()(64bit) for package: 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64
--> Processing Dependency: libexslt.so.0()(64bit) for package: 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64
---> Package nginx-mod-mail.x86_64 1:1.12.2-2.el7 will be installed
---> Package nginx-mod-stream.x86_64 1:1.12.2-2.el7 will be installed
--> Running transaction check
---> Package GeoIP.x86_64 0:1.5.0-13.el7 will be installed
---> Package gd.x86_64 0:2.0.35-26.el7 will be installed
--> Processing Dependency: libpng15.so.15(PNG15_0)(64bit) for package: gd-2.0.35-26.el7.x86_64
--> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: gd-2.0.35-26.el7.x86_64
--> Processing Dependency: libpng15.so.15()(64bit) for package: gd-2.0.35-26.el7.x86_64
--> Processing Dependency: libjpeg.so.62()(64bit) for package: gd-2.0.35-26.el7.x86_64
--> Processing Dependency: libfreetype.so.6()(64bit) for package: gd-2.0.35-26.el7.x86_64
--> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd-2.0.35-26.el7.x86_64
--> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-26.el7.x86_64
--> Processing Dependency: libX11.so.6()(64bit) for package: gd-2.0.35-26.el7.x86_64
---> Package libxslt.x86_64 0:1.1.28-5.el7 will be installed
---> Package perl.x86_64 4:5.16.3-293.el7 will be installed
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-293.el7.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-293.el7.x86_64
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-libs.x86_64 4:5.16.3-293.el7 will be installed
--> Running transaction check
---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed
--> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64
--> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64
---> Package freetype.x86_64 0:2.8-12.el7 will be installed
---> Package libX11.x86_64 0:1.6.5-2.el7 will be installed
--> Processing Dependency: libX11-common >= 1.6.5-2.el7 for package: libX11-1.6.5-2.el7.x86_64
--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.5-2.el7.x86_64
---> Package libXpm.x86_64 0:3.5.12-1.el7 will be installed
---> Package libjpeg-turbo.x86_64 0:1.2.90-6.el7 will be installed
---> Package libpng.x86_64 2:1.5.13-7.el7_2 will be installed
---> Package perl-Carp.noarch 0:1.26-244.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-4.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-macros.x86_64 4:5.16.3-293.el7 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
--> Running transaction check
---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed
--> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch
---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
---> Package libX11-common.noarch 0:1.6.5-2.el7 will be installed
---> Package libxcb.x86_64 0:1.13-1.el7 will be installed
--> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.13-1.el7.x86_64
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-293.el7 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 dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
---> 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:
nginx x86_64 1:1.12.2-2.el7 epel 530 k
Installing for dependencies:
GeoIP x86_64 1.5.0-13.el7 base 1.5 M
dejavu-fonts-common noarch 2.33-6.el7 base 64 k
dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
fontconfig x86_64 2.13.0-4.3.el7 base 254 k
fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k
freetype x86_64 2.8-12.el7 base 380 k
gd x86_64 2.0.35-26.el7 base 146 k
gperftools-libs x86_64 2.6.1-1.el7 base 272 k
groff-base x86_64 1.22.2-8.el7 base 942 k
libX11 x86_64 1.6.5-2.el7 base 606 k
libX11-common noarch 1.6.5-2.el7 base 164 k
libXau x86_64 1.0.8-2.1.el7 base 29 k
libXpm x86_64 3.5.12-1.el7 base 55 k
libjpeg-turbo x86_64 1.2.90-6.el7 base 134 k
libpng x86_64 2:1.5.13-7.el7_2 base 213 k
libxcb x86_64 1.13-1.el7 base 214 k
libxslt x86_64 1.1.28-5.el7 base 242 k
make x86_64 1:3.82-23.el7 base 420 k
nginx-all-modules noarch 1:1.12.2-2.el7 epel 16 k
nginx-filesystem noarch 1:1.12.2-2.el7 epel 17 k
nginx-mod-http-geoip x86_64 1:1.12.2-2.el7 epel 23 k
nginx-mod-http-image-filter x86_64 1:1.12.2-2.el7 epel 26 k
nginx-mod-http-perl x86_64 1:1.12.2-2.el7 epel 36 k
nginx-mod-http-xslt-filter x86_64 1:1.12.2-2.el7 epel 26 k
nginx-mod-mail x86_64 1:1.12.2-2.el7 epel 54 k
nginx-mod-stream x86_64 1:1.12.2-2.el7 epel 76 k
openssl x86_64 1:1.0.2k-16.el7 base 493 k
perl x86_64 4:5.16.3-293.el7 base 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-293.el7 base 51 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-4.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-293.el7 base 688 k
perl-macros x86_64 4:5.16.3-293.el7 base 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
Transaction Summary
================================================================================
Install 1 Package (+54 Dependent packages)
Total download size: 20 M
Installed size: 61 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/nginx-1.12.2-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for nginx-1.12.2-2.el7.x86_64.rpm is not installed
--------------------------------------------------------------------------------
Total 3.5 MB/s | 20 MB 00:05
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid : "Fedora EPEL (7) <epel@fedoraproject.org>"
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package : epel-release-7-11.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : fontpackages-filesystem-1.44-8.el7.noarch 1/55
Installing : 2:libpng-1.5.13-7.el7_2.x86_64 2/55
Installing : freetype-2.8-12.el7.x86_64 3/55
Installing : dejavu-fonts-common-2.33-6.el7.noarch 4/55
Installing : dejavu-sans-fonts-2.33-6.el7.noarch 5/55
Installing : fontconfig-2.13.0-4.3.el7.x86_64 6/55
Installing : libXau-1.0.8-2.1.el7.x86_64 7/55
Installing : libxcb-1.13-1.el7.x86_64 8/55
Installing : libX11-common-1.6.5-2.el7.noarch 9/55
Installing : libX11-1.6.5-2.el7.x86_64 10/55
Installing : libXpm-3.5.12-1.el7.x86_64 11/55
Installing : gperftools-libs-2.6.1-1.el7.x86_64 12/55
Installing : 1:make-3.82-23.el7.x86_64 13/55
Installing : 1:openssl-1.0.2k-16.el7.x86_64 14/55
Installing : libxslt-1.1.28-5.el7.x86_64 15/55
Installing : 1:nginx-filesystem-1.12.2-2.el7.noarch 16/55
Installing : libjpeg-turbo-1.2.90-6.el7.x86_64 17/55
Installing : gd-2.0.35-26.el7.x86_64 18/55
Installing : groff-base-1.22.2-8.el7.x86_64 19/55
Installing : 1:perl-parent-0.225-244.el7.noarch 20/55
Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 21/55
Installing : perl-podlators-2.5.1-3.el7.noarch 22/55
Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 23/55
Installing : 1:perl-Pod-Escapes-1.04-293.el7.noarch 24/55
Installing : perl-Text-ParseWords-3.29-4.el7.noarch 25/55
Installing : perl-Encode-2.51-7.el7.x86_64 26/55
Installing : perl-Pod-Usage-1.63-3.el7.noarch 27/55
Installing : 4:perl-macros-5.16.3-293.el7.x86_64 28/55
Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 29/55
Installing : perl-Exporter-5.68-3.el7.noarch 30/55
Installing : perl-constant-1.27-2.el7.noarch 31/55
Installing : perl-Time-Local-1.2300-2.el7.noarch 32/55
Installing : perl-Socket-2.010-4.el7.x86_64 33/55
Installing : perl-Carp-1.26-244.el7.noarch 34/55
Installing : perl-Storable-2.45-3.el7.x86_64 35/55
Installing : perl-PathTools-3.40-5.el7.x86_64 36/55
Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 37/55
Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 38/55
Installing : perl-File-Temp-0.23.01-3.el7.noarch 39/55
Installing : perl-File-Path-2.09-2.el7.noarch 40/55
Installing : perl-threads-shared-1.43-6.el7.x86_64 41/55
Installing : perl-threads-1.87-4.el7.x86_64 42/55
Installing : perl-Filter-1.49-3.el7.x86_64 43/55
Installing : 4:perl-libs-5.16.3-293.el7.x86_64 44/55
Installing : perl-Getopt-Long-2.40-3.el7.noarch 45/55
Installing : 4:perl-5.16.3-293.el7.x86_64 46/55
Installing : GeoIP-1.5.0-13.el7.x86_64 47/55
Installing : 1:nginx-mod-http-geoip-1.12.2-2.el7.x86_64 48/55
Installing : 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64 49/55
Installing : 1:nginx-mod-stream-1.12.2-2.el7.x86_64 50/55
Installing : 1:nginx-mod-mail-1.12.2-2.el7.x86_64 51/55
Installing : 1:nginx-mod-http-image-filter-1.12.2-2.el7.x86_64 52/55
Installing : 1:nginx-1.12.2-2.el7.x86_64 53/55
Installing : 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 54/55
Installing : 1:nginx-all-modules-1.12.2-2.el7.noarch 55/55
Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/55
Verifying : fontconfig-2.13.0-4.3.el7.x86_64 2/55
Verifying : 2:libpng-1.5.13-7.el7_2.x86_64 3/55
Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 4/55
Verifying : perl-threads-shared-1.43-6.el7.x86_64 5/55
Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 6/55
Verifying : 1:nginx-mod-http-geoip-1.12.2-2.el7.x86_64 7/55
Verifying : perl-Exporter-5.68-3.el7.noarch 8/55
Verifying : perl-constant-1.27-2.el7.noarch 9/55
Verifying : perl-PathTools-3.40-5.el7.x86_64 10/55
Verifying : 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64 11/55
Verifying : 4:perl-macros-5.16.3-293.el7.x86_64 12/55
Verifying : fontpackages-filesystem-1.44-8.el7.noarch 13/55
Verifying : 1:nginx-mod-stream-1.12.2-2.el7.x86_64 14/55
Verifying : freetype-2.8-12.el7.x86_64 15/55
Verifying : 1:perl-parent-0.225-244.el7.noarch 16/55
Verifying : GeoIP-1.5.0-13.el7.x86_64 17/55
Verifying : groff-base-1.22.2-8.el7.x86_64 18/55
Verifying : perl-File-Temp-0.23.01-3.el7.noarch 19/55
Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 20/55
Verifying : 1:nginx-all-modules-1.12.2-2.el7.noarch 21/55
Verifying : 1:openssl-1.0.2k-16.el7.x86_64 22/55
Verifying : 1:perl-Pod-Escapes-1.04-293.el7.noarch 23/55
Verifying : perl-Time-Local-1.2300-2.el7.noarch 24/55
Verifying : libjpeg-turbo-1.2.90-6.el7.x86_64 25/55
Verifying : perl-Socket-2.010-4.el7.x86_64 26/55
Verifying : libXpm-3.5.12-1.el7.x86_64 27/55
Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 28/55
Verifying : 1:nginx-filesystem-1.12.2-2.el7.noarch 29/55
Verifying : perl-Carp-1.26-244.el7.noarch 30/55
Verifying : libxcb-1.13-1.el7.x86_64 31/55
Verifying : libxslt-1.1.28-5.el7.x86_64 32/55
Verifying : libX11-1.6.5-2.el7.x86_64 33/55
Verifying : perl-Storable-2.45-3.el7.x86_64 34/55
Verifying : dejavu-sans-fonts-2.33-6.el7.noarch 35/55
Verifying : 1:nginx-mod-mail-1.12.2-2.el7.x86_64 36/55
Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 37/55
Verifying : 1:make-3.82-23.el7.x86_64 38/55
Verifying : 1:nginx-mod-http-image-filter-1.12.2-2.el7.x86_64 39/55
Verifying : perl-Pod-Usage-1.63-3.el7.noarch 40/55
Verifying : perl-Encode-2.51-7.el7.x86_64 41/55
Verifying : 1:nginx-1.12.2-2.el7.x86_64 42/55
Verifying : dejavu-fonts-common-2.33-6.el7.noarch 43/55
Verifying : perl-podlators-2.5.1-3.el7.noarch 44/55
Verifying : 4:perl-5.16.3-293.el7.x86_64 45/55
Verifying : perl-File-Path-2.09-2.el7.noarch 46/55
Verifying : perl-threads-1.87-4.el7.x86_64 47/55
Verifying : gperftools-libs-2.6.1-1.el7.x86_64 48/55
Verifying : libX11-common-1.6.5-2.el7.noarch 49/55
Verifying : libXau-1.0.8-2.1.el7.x86_64 50/55
Verifying : perl-Filter-1.49-3.el7.x86_64 51/55
Verifying : perl-Getopt-Long-2.40-3.el7.noarch 52/55
Verifying : 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 53/55
Verifying : gd-2.0.35-26.el7.x86_64 54/55
Verifying : 4:perl-libs-5.16.3-293.el7.x86_64 55/55
Installed:
nginx.x86_64 1:1.12.2-2.el7
Dependency Installed:
GeoIP.x86_64 0:1.5.0-13.el7
dejavu-fonts-common.noarch 0:2.33-6.el7
dejavu-sans-fonts.noarch 0:2.33-6.el7
fontconfig.x86_64 0:2.13.0-4.3.el7
fontpackages-filesystem.noarch 0:1.44-8.el7
freetype.x86_64 0:2.8-12.el7
gd.x86_64 0:2.0.35-26.el7
gperftools-libs.x86_64 0:2.6.1-1.el7
groff-base.x86_64 0:1.22.2-8.el7
libX11.x86_64 0:1.6.5-2.el7
libX11-common.noarch 0:1.6.5-2.el7
libXau.x86_64 0:1.0.8-2.1.el7
libXpm.x86_64 0:3.5.12-1.el7
libjpeg-turbo.x86_64 0:1.2.90-6.el7
libpng.x86_64 2:1.5.13-7.el7_2
libxcb.x86_64 0:1.13-1.el7
libxslt.x86_64 0:1.1.28-5.el7
make.x86_64 1:3.82-23.el7
nginx-all-modules.noarch 1:1.12.2-2.el7
nginx-filesystem.noarch 1:1.12.2-2.el7
nginx-mod-http-geoip.x86_64 1:1.12.2-2.el7
nginx-mod-http-image-filter.x86_64 1:1.12.2-2.el7
nginx-mod-http-perl.x86_64 1:1.12.2-2.el7
nginx-mod-http-xslt-filter.x86_64 1:1.12.2-2.el7
nginx-mod-mail.x86_64 1:1.12.2-2.el7
nginx-mod-stream.x86_64 1:1.12.2-2.el7
openssl.x86_64 1:1.0.2k-16.el7
perl.x86_64 4:5.16.3-293.el7
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-293.el7
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-4.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-293.el7
perl-macros.x86_64 4:5.16.3-293.el7
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
Complete!
---> bd938f3bd351
Removing intermediate container 62c192226b85
Step 4/4 : ADD index.html usr/share/nginx/html/
---> b5c65161f935
Removing intermediate container 012a4c6817a4
Successfully built b5c65161f935
[root@node5 nginx]#
[root@node5 nginx]# docker run --name nginx --rm -it -P b5c65161f935
[root@3beff59afc75 /]# cd /usr/share/nginx/html/
[root@3beff59afc75 html]# ls
404.html 50x.html index.html nginx-logo.png poweredby.png
[root@3beff59afc75 html]# cat index.html
<h1>Nginx Server Test Home Page </h1>
[root@3beff59afc75 html]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@3beff59afc75 html]# nginx
[root@3beff59afc75 html]#
测试:
[root@node5 ~]# docker inspect test1
"NetworkSettings": {
"Bridge": "",
"SandboxID": "2978668ae3dffc67d99a50562b054fa05004de5553a05ef79a3e12c866a22bc9",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/2978668ae3df",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "66a2b1e54e6c5a0d913c1122b1386982a17155bdbd2aaa226d0697465ebf6e97",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.8",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:08",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "eaa0eed9a4d2a09ab421188b1a8d16fab68541357bdec0e5382b71b0019b4923",
"EndpointID": "66a2b1e54e6c5a0d913c1122b1386982a17155bdbd2aaa226d0697465ebf6e97",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.8",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:08"
}
}
}
}
[root@node5 ~]# curl http://172.17.0.8
<h1>Nginx Server Test Home Page </h1>
[root@node5 ~]#
CMD指令:类似于RUN指令,用于运行程序;但二者运行的时间点不同;CMD在docker run时运行,而非docker build;
CMD指令的首要目的在于为启动的容器指定默认要运行的程序,程序运行结束,容器也就结束;不过,CMD指令指定的程序可被docker run命令行参数中指定要运行的程序所覆盖。
语法格式:
CMD <command> 或
CMD ["<executeable>", "<param1>", "<param2>", ...] 或
CMD [ "<param1>", "<param2>", ...]
第三种为ENTRYPOINT指令指定的程序提供默认参数;
注意:如果dockerfile中存在多个CMD指令,仅最后一个生效;
CMD ["/usr/sbin/httpd", "-c","/etc/httpd/conf/httpd.conf"]
[root@node5 nginx2]# vi Dockerfile
FROM docker.io/wangjinhuai/nginx:latest
MAINTAINER "magedu<magedu@magedu>"
EXPOSE 80/tcp
CMD ["/usr/sbin/nginx","-g","daemon off;"]
[root@node5 nginx2]# docker build ./
Sending build context to Docker daemon 2.048 kB
Step 1/4 : FROM docker.io/wangjinhuai/nginx:latest
---> b5c65161f935
Step 2/4 : MAINTAINER "magedu<magedu@magedu>"
---> Running in a3bc50cbc571
---> afee10050039
Removing intermediate container a3bc50cbc571
Step 3/4 : EXPOSE 80/tcp
---> Running in 390875002dbe
---> c0fb7f9ef5c2
Removing intermediate container 390875002dbe
Step 4/4 : CMD /usr/sbin/nginx -g daemon off;
---> Running in aec7339389a0
---> d31d0b5ed583
Removing intermediate container aec7339389a0
Successfully built d31d0b5ed583
[root@node5 nginx2]# docker run --name nginx --rm -it -P d31d0b5ed583
[root@node5 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d846b8de70f d31d0b5ed583 "/usr/sbin/nginx -..." 5 minutes ago Up 5 minutes 0.0.0.0:32774->80/tcp nginx
[root@node5 ~]# curl http://192.168.170.30:32774
<h1>Nginx Server Test Home Page </h1>