Reference article: https://www.cnblogs.com/boundless-sky/p/7182410.html
1. Download the image
Docker Pull Nginx
Docker Pull PHP:7.2.4-FPM
2. Make a nginx configuration file: Run a container and delete the container after default.conf.
Docker run--name mynginx_test-d-P 28369:80 nginx
Docker CP mynginx_test:/etc/nginx/conf.d/default.conf./default.conf
Docker Stop Mynginx_test
Docker RM mynginx_test
3. Preparing the Environment
Copy the above default.conf to/home/wyt/docker_data/nginx, and then modify the contents:
Location/{
root/usr/share/nginx/html;
Index index.html index.htm index.php;
}
Location ~ \.php$ {
Fastcgi_pass php:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename/var/www/html/$fastcgi _script_name;
Include Fastcgi_params;
}
Prepare/home/wyt/docker_data/www to store Web pages
4. Running the container
Docker run--name myphp-d-v/home/wyt/docker_data/www:/var/www/html php:7.2.4-fpm
Docker run--name mynginx-d-P 80:80-v/home/wyt/docker_data/www:/usr/share/nginx/html \
-V/HOME/WYT/DOCKER_DATA/NGINX:/ETC/NGINX/CONF.D--link myphp:php Nginx
5. Testing
Put 2 test files in/home/wyt/docker_data/www index.html and test/index.php
6. Description
Default.conf inside php:9000 means to find the PHP server in the DNS, and the back link is to put it into the DNS resolution
Docker install Nginx and PHP