码迷,mamicode.com
首页 > 其他好文 > 详细

Dockerfile(七)安装nginx

时间:2018-04-12 18:04:15      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:docker

Dockerfile安装nginx

写一个Dockerfile文件

FROM centos
MAINTAINER apeng apeng@apenglinux-002.com
RUN 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.gz
RUN mkdir -p /usr/local/nginx
RUN cd nginx-1.8.0 && ./configure --prefix=/usr/local/nginx && make -j 4 && make -j 4  install
RUN rm -fv /usr/local/nginx/conf/nginx.conf
ADD http://www.apelearn.com/study_v2/.nginx_conf  /usr/local/nginx/conf/nginx.conf
EXPOSE 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 images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
centos              nginx               cafeea92311c        About a minute ago   372MB
centos              latest              e934aafc2206        2 days ago           199MB

映射容器端口

[root@apenglinux-002 ~]# docker run -itd -p 80:80 centos:nginx /bin/bash
37531c1c18a176dd9fb2f77620e3285100628f86c21e0cfc887f2b8746670019

在浏览器中访问

技术分享图片

Dockerfile(七)安装nginx

标签:docker

原文地址:http://blog.51cto.com/13480443/2097526

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!