1.拉取nginx镜像
Docker pull nginx
mkdir www cd www
mkdir /www/wwwroot
mkdir /www/wwwroot/php
mkdir server cd server
mkdir nginx cd nginx
mkdir conf cd conf
touch default.conf
vim default.conf
server {
listen 80;
listen [::]:80; //映射宿主机的配置
server_name localhost;
root /www/wwwroot/php;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /docker/www /lmrs-2008/public;
}
location ~ \.php$ {
root /www/wwwroot/php;
fastcgi_pass 172.17.0.3:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
docker run -p 80:80 -d --name nginx -v /www/server/nginx/conf/default.conf:/etc/nginx/conf.d/default.conf -v /www/wwwroot/php:/www/wwwroot/php --privileged=true nginx
docker ps