l先下载nginx的配置文件 wget http://www.apelearn.com/study_v2/.nginx_conf
lvim Dockerfile //内容如下
############################################################
# Dockerfile to build Nginx Installed Containers
# Based on CentOS
############################################################
# Set the base image to CentOS
FROM centos
# File Author / Maintainer
MAINTAINER aming aming@aminglinux.com
# Install necessary tools
RUN yum install -y pcre-devel wget net-tools gcc
RUN yum install -y zlib zlib-devel make
RUN yum install -y openssl-devel
l# Install Nginx
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
lRUN cd nginx-1.8.0.tar.gz && ./configure --prefix=/usr/local/nginx && make && make install
RUN rm -fv /usr/local/nginx/conf/nginx.conf
COPY .nginx_conf /usr/local/nginx/conf/nginx.conf
# Expose ports
EXPOSE 80
# Set the default command to execute
# when creating a new container
ENTRYPOINT /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
l创建镜像:
ldocker build -t centos_nginx .
ldocker images 可以看到我们新建的镜像
原文地址:http://xiongrunchu.blog.51cto.com/11696174/1788201