我想構建一個Docker鏡像來運行我的Symfony3應用程序。Symfony docker配置
我有docker-composer.yml
和site.conf
在我的碼頭工人作曲家我定義了兩個集裝箱web
和php
和鏈接這些cntainers:
web:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./code/test:/var/www/test
- ./site.conf:/etc/nginx/conf.d/default.conf
links:
- php
php:
image: php:7-fpm
volumes:
- ./code/test:/var/www/test
我發現如何設置我的網站官方nginx的docs。 conf:
my site.conf:
server {
server_name test-docker.local;
root /code/test/web;
location/{
try_files $uri /app.php$is_args$args;
}
# DEV
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
在相同的目錄中,我有我的docker.compose.yml和site.conf我有代碼目錄和代碼目錄裏面我有測試目錄和內部測試死它的我的PHP應用程序。
我的問題是,當我去我的根URL test-docker.local/
我得到File Not Found
我進入PHP的容器,看代碼得到複製到正確的路徑,它是/ var/www/test/
當我在同一路徑/ var/www/test下輸入我的web容器時,代碼id是nginx容器的正確路徑,那是nginx加載代碼...?即使如此,爲什麼nginx容器必須有代碼的副本,如果理論上的代碼應該從PHP容器加載?