本文共 1147 字,大约阅读时间需要 3 分钟。
Dockerfile安装nginx
写一个Dockerfile文件
FROM centosMAINTAINER apeng apeng@apenglinux-002.comRUN yum install -y pcre-devel wget net-tools gcc zlib zlib-devel make openssl-devel ADD http://nginx.org/download/nginx-1.8.0.tar.gz .RUN tar zxvf nginx-1.8.0.tar.gzRUN mkdir -p /usr/local/nginxRUN cd nginx-1.8.0 && ./configure --prefix=/usr/local/nginx && make -j 4 && make -j 4 installRUN rm -fv /usr/local/nginx/conf/nginx.confADD http://www.apelearn.com/study_v2/.nginx_conf /usr/local/nginx/conf/nginx.confEXPOSE 80 ENTRYPOINT /usr/local/nginx/sbin/nginx && tail -f /etc/passwd
创建新的images为centos:nginx
[root@apenglinux-002 ~]# docker build -t centos:nginx .
查看镜像
[root@apenglinux-002 ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEcentos nginx cafeea92311c About a minute ago 372MBcentos latest e934aafc2206 2 days ago 199MB
映射容器端口
[root@apenglinux-002 ~]# docker run -itd -p 80:80 centos:nginx /bin/bash37531c1c18a176dd9fb2f77620e3285100628f86c21e0cfc887f2b8746670019
在浏览器中访问
转载于:https://blog.51cto.com/13480443/2097526