Docker: Build nginx + php-fpm image (1): Build nginx self-starting image, nginxphp-fpm
Step 1: manually install the nginx environment and record the entire process:# Use yum to update the system yum-y update # compile and install tengine below to check which packages need to be installed # Install the wget package, used to obtain the installation package yum-y install wget cd/usr/local/src # download the nginx installation package, and specify the directory/usr/local/srcwget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz-P/usr/local/src/unzip zmatching .gz x unzip f local tar-zxf tengine-2.1.2.tar.gz # create nginx users and groups groupadd-r nginxuseradd-g nginx-M nginx # tengine initial compilation. /configure -- prefix =/usr/local/tengine \ -- user = nginx -- group = nginx # report an error and supplement the system package: yum-y install gcc pcre-devel openssl-devel # The first compilation is passed, and the nginx module configuration is added for re-Compilation: -- with-http_realip_module # nginx get client real IP Module -- with-http_sub_module # used to replace the website page keywords -- common basic nothing -- with-http_gzip_static_module # static cache compression, used to reduce traffic -- with-http_gunzip_module # provides decompression service for clients that do not support the gzip module, to save space to reduce IO -- with-http_ssl_module # Make nginx support https -- with-pcre # nginx support pcre regular, mainly support rewrite function -- with-http_stub_status_module # for monitoring nginx status complete compilation command is as follows:
./configure --prefix=/usr/local/tengine \--user=nginx --group=nginx \--with-http_realip_module \--with-http_gzip_static_module \--with-http_gunzip_module \--with-pcre \--with-http_stub_status_module \--with-http_ssl_module
# Compile and install make & make install # Start nginx/usr/local/tengine/sbin/nginx Step 2: Build dockerfile to generate nginx image Dockerfile
####################################################Dockerfile to build mysqlDB container images#base on centos####################################################Set the base image to Centos6FROM centos:6#File SuthorMAINTAINER liujian@wanbu.com.cn #install basic rpmRUN yum -y updateRUN yum -y install wget gcc pcre-devel openssl-develRUN wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz -P /usr/local/src/ \&& groupadd -r nginx && useradd -g nginx -M nginxRUN cd /usr/local/src/ \&& tar -zxf tengine-2.1.2.tar.gz \&& cd tengine-2.1.2/ \&& ./configure --prefix=/usr/local/tengine --user=nginx --group=nginx --with-http_realip_module --with-http_gzip_static_module --with-http_gunzip_module --with-pcre --with-http_stub_status_module --with-http_ssl_module \&& make && make install \&& ln -s /usr/local/tengine/sbin/nginx /usr/sbin/nginx \&& yum -y remove wget gcc pcre-devel openssl-develADD nginx.conf /usr/local/tengine/conf/EXPOSE 80CMD ["nginx","-g","deamon off;"]
# Develop Dokcerfile to build the nginx image docker build-t nginx_test: v1.0. # use an image to create a container and test nginx running condition: docker run-itd-p 0.0.0.0: 7788: 80 -- name nginx_image_test nginx_test: v1.0 # access is normal, but the nginx configuration file cannot be modified, you can only start running. If you need to modify the configuration file and restart it in the test environment, you can use: # change the dockerfile internal CMD ["nginx", "-g", "deamon off; "] Replace with ENTRYPOINT/usr/sbin/nginx-c/etc/nginx. conf &/bin/bash