我按照这个指南在Docker上运行PHP,但是Nginx并没有指向我在site.conf中设置的根目录。
泊坞窗,compose.yml:
Nginx: image: Nginx:latest ports: - 8080:80 volumes: - ./code:/code - ./site.conf:/etc/Nginx/conf.d/site.conf links: - PHP PHP: image: PHP:7-fpm volumes: - ./code:/code
site.conf:
server { index index.PHP index.html; server_name localhost; error_log /var/log/Nginx/error.log; access_log /var/log/Nginx/access.log; root /code; location ~ .PHP$ { try_files $uri =404; fastcgi_split_path_info ^(.+.PHP)(/.+)$; fastcgi_pass PHP:9000; fastcgi_index index.PHP; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }
Docker – index.html Nginx文件的无效共享
如何在linux主机上的docker容器中安装一个目录
Docker暴露端口疯狂
在我的terminal上,我运行:
docker-compose up
结果:
但应该是:
任何想法为什么?
编辑:
server { index index.PHP index.html; server_name docker.loc; error_log /var/log/Nginx/error.log; access_log /var/log/Nginx/access.log; root /code; location ~ .PHP$ { try_files $uri =404; fastcgi_split_path_info ^(.+.PHP)(/.+)$; fastcgi_pass PHP:9000; fastcgi_index index.PHP; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }
当我运行docker-compose up时出现这个错误:
Nginx_1 | 172.17.0.1 - - [01/Jan/2017:20:35:17 +0000] "GET / HTTP/1.1" 403 571 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML,like Gecko) Ubuntu Chromium/55.0.2883.87 Chrome/55.0.2883.87 Safari/537.36" Nginx_1 | 2017/01/01 20:35:17 [error] 6#6: *5 directory index of "/code/" is forbidden,client: 172.17.0.1,server: docker.PHP,request: "GET / HTTP/1.1",host: "docker.PHP:8080"
docker.PHP从哪里来?
在一台主机上运行两个docker组合应用程序的最好方法是在Nginx后面运行?
错误 – Docker-compose / docker Windows
sudo:docker-compose:command not found
Docker-Compose无法连接到Docker Daemon
DOCKER for Windows – 打开cmd执行docker机器env
你有域名冲突。 设置server_name docker.loc; 在site.conf中。 然后将127.0.0.1 docker.loc添加到本地计算机上的/ etc / hosts中。 然后,您可以通过docker.loc:8080访问dockerised应用程序