整合 nginx php-fpm
github https://github.com/shiphp/nginx-env 稍加修改
vim dockerfile
# This is a commit FROM shiphp/nginx-env:latest MAINTAINER love coding <237356573@qq.com> USER root RUN groupadd -g 1000 www && useradd -u1001 -g www -M -s /bin/nologin www RUN mkdir -p /usr/www/html && chown -R www:www /usr/www/html RUN rm -f /etc/nginx/conf.d/default.conf COPY default.conf /etc/nginx/conf.d/default.conf RUN chown -R www:www /etc/nginx EXPOSE 80
docker build -t nginx:v1 .
vim default.conf
server { listen 80; index index.php index.html; root /usr/www/html; client_max_body_size 32M; location / { try_files $uri /index.php?$args; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass $ENV{"NGINX_HOST"}:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }
php : docker run -d --name php-fpm-api -v /usr/local/nginx/www:/usr/www/html php-fpm:v6 nginx: docker run -d --name nginx -d -p 80:80 -v /usr/local/nginx/www:/usr/www/html --link php-fpm-api -e NGINX_HOST=php-fpm-api nginx:v1