~~~
FROM centos
ENV NGINX_VERSION nginx-1.14.1
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& yum install -y epel-release \
&& yum update -y
RUN yum install -y wget make gcc pcre-devel openssl-devel \
&& wget -O /root/$NGINX_VERSION.tar.gz http://mirror.revoke.cc/nginx/$NGINX_VERSION.tar.gz \
&& tar -zxf /root/$NGINX_VERSION.tar.gz -C /root/ \
&& cd /root/$NGINX_VERSION/ \
&& ./configure --prefix=/usr/local/nginx \
--pid-path=/usr/local/nginx/run/nginx.pid \
--with-http_ssl_module \
--with-http_realip_module \
--with-pcre \
&& make \
&& make install \
&& cd /root/ \
&& rm -rf /root/$NGINX_VERSION.tar.gz /root/$NGINX_VERSION/ \
&& echo -e "[Unit]\n\
Description=The NGINX HTTP and reverse proxy server\n\
After=syslog.target network.target remote-fs.target nss-lookup.target\n\
\n\
[Service]\n\
Type=forking\n\
PIDFile=/usr/local/nginx/run/nginx.pid\n\
ExecStartPre=/usr/local/nginx/sbin/nginx -t\n\
ExecStart=/usr/local/nginx/sbin/nginx\n\
ExecReload=/usr/local/nginx/sbin/nginx -s reload\n\
ExecStop=/bin/kill -s QUIT $MAINPID\n\
PrivateTmp=true\n\
\n\
[Install]\n\
WantedBy=multi-user.target" > /usr/lib/systemd/system/nginx.service \
&& systemctl enable nginx
ENV PATH /usr/local/nginx/sbin:$PATH
EXPOSE 80 443
ENTRYPOINT /usr/sbin/init
~~~