下载镜像
docker pull bitnami/php-fpm #下载php-fpm镜像 docker pull nginx #下载nginx镜像
创建volume
docker volume create webpage #用于容器web页面存放,存储位置默认为:/var/lib/docker/volume/webpage/_data/
创建php-fpm、nginx镜像
docker run -d --name php-fpm -v webpage:/usr/share/nginx/html bitnami/php-fpm
docker run -d --name nginx -p 8888:80 -v webpage:/usr/share/nginx/html --link php-fpm:php-fpm nginx
修改docker下default.conf文件,文件目录/etc/nginx/conf.d/default.conf ,内容如下:
server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { fastcgi_pass php:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; include fastcgi_params; }}
若不方便修改,可以使用docker cp命令,在宿主机上写好再复制到容器中替换,复制命令如下:
docker cp default.conf nginx:/etc/nginx/conf.d/default.conf
重启nginx容器
docker restart nginx
原文地址:https://www.cnblogs.com/yyxianren/p/10722940.html
时间: 2024-11-13 10:23:32