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
在浏览器中访问
原文地址:http://blog.51cto.com/13480443/2097526
时间: 2024-11-08 22:36:17