1. Download Nginx configuration file wget http://www.apelearn.com/study_v2/.nginx_conf
2. Vim Dockerfile
#本地有centos的镜像, you can specify the image name directly, and if you need to download another version of the image from the Docker website, modify the version number yourself
From centos:6.8
Maintainer Wyman [email protected]
#根据实际需要选择安装
RUN Yum install-y pcre-devel wget net-tools gcc zlib zlib-devel make Openssl-devel tar
ADD Http://nginx.org/download/nginx-1.8.0.tar.gz/root
RUN Tar zxf/root/nginx-1.8.0.tar.gz
RUN mkdir-p/usr/local/nginx
RUN cd/root/nginx-1.8.0 &&./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
RUN RM-FV nginx-1.8.0.tar.gz
EXPOSE 80
3. Create an image file
Docker build-t Centos_nginx. which. Represents the path to the file where the Dockerfile resides
Creating an Nginx service container image using Dockerfile