Dockerfile安装nginx
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dockerfile安装nginx相关的知识,希望对你有一定的参考价值。
Dockerfile安装nginx
写一个Dockerfile文件
FROM centos
MAINTAINER apeng [email protected]
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
[[email protected] ~]# docker build -t centos:nginx .
查看镜像
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos nginx cafeea92311c About a minute ago 372MB
centos latest e934aafc2206 2 days ago 199MB
映射容器端口
[[email protected] ~]# docker run -itd -p 80:80 centos:nginx /bin/bash
37531c1c18a176dd9fb2f77620e3285100628f86c21e0cfc887f2b8746670019
在浏览器中访问
以上是关于Dockerfile安装nginx的主要内容,如果未能解决你的问题,请参考以下文章
Docker中Dockerfile的格式Dockerfile安装nginx实例