全步驟:
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
{
"registry-mirrors": ["https://w1ogxqvl.mirror.aliyuncs.com"]
}
EOF
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 7 5e35e350aded 6 weeks ago 203MB
[root@localhost ~]
[root@localhost opt]
[root@localhost opt]
[root@localhost nginx]
FROM 5e35e350aded
MAINTAINER The is nginx <zjx>
RUN yum install -y proc-devel gcc gcc-c++ zlib zlib-devel make openssl-devel wget
RUN wget http://nginx.org/download/nginx-1.9.7.tar.gz
RUN tar zxvf nginx-1.9.7.tar.gz
WORKDIR nginx-1.9.7/
RUN ./configure --prefix=/usr/local/nginx && make && make install
EXPOSE 80
EXPOSE 443
RUN echo "daemon off;" >>/usr/local/nginx/conf/nginx.conf
WORKDIR /root/nginx
ADD run.sh /run.sh
RUN chmod 755 /run.sh
CMD ["/run.sh"]
[root@localhost nginx]
/usr/local/nginx/sbin/nginx
[root@localhost nginx]
[root@localhost nginx]
1e42f3a46caf349a964c4304b900ecb406102e3dc7e5beae16293f071470e54b
[root@localhost nginx]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1e42f3a46caf nginx:new "/run.sh" 8 seconds ago Up 7 seconds 0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcp hardcore_cerf
驗證:回到宿主機在瀏覽器中訪問CentOS的IP地址的32769端口,看是否可以訪問Nginx主頁