Docker机器用户无法访问主机上的文件

我有在远程计算机上设置我的docker环境的问题。

我准备了当地的docker机器。 问题在于nginx + php-fpm。

Nginx充当nginx用户,php-fpm充当www-data用户。 主机上的文件(应用程序文件)由user1拥有。 chmods是symfony2应用程序的默认设置。

当我访问我的networking服务器时,它返回404错误或只是简单的“找不到文件”。

有一段时间,我的本地Ubuntu 16.04上完全相同的configuration工作,但在服务器上的Debian Jessie失败。 现在它不适用于这两个。 我尝试了一切,在系统pipe理员组织上询问并search了几个小时。 你有什么想法吗?

这是我的虚拟主机configuration

server { listen 80; server_name dev.xxxxx.co xxxxx.dev; root /usr/share/www/co.xxxxx.dev/web; index app_dev.php; client_max_body_size 100M; fastcgi_read_timeout 1800; location / { # try to serve file directly, fallback to app.php try_files $uri $uri/ /app.php$is_args$args; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; access_log off; } location ~ ^/(app_dev|config)\.php(/|$) { fastcgi_pass php-fpm:9000; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; # When you are using symlinks to link the document root to the # current version of your application, you should pass the real # application path instead of the path to the symlink to PHP # FPM. # Otherwise, PHP's OPcache may not properly detect changes to # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; } location ~ ^/app\.php(/|$) { fastcgi_pass php-fpm:9000; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; # When you are using symlinks to link the document root to the # current version of your application, you should pass the real # application path instead of the path to the symlink to PHP # FPM. # Otherwise, PHP's OPcache may not properly detect changes to # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; # Prevents URIs that include the front controller. This will 404: # http://domain.tld/app.php/some-path # Remove the internal directive to allow URIs like this internal; } location ~ \.php$ { return 404; } } 

nginxconfiguration

 user root; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } 

我的docker工作

 version: '2' services: nginx: image: nginx ports: - 8082:80 volumes: - /home/konrad/Workspace:/usr/share/www:ro - ./conf/nginx.conf:/etc/nginx/nginx.conf:ro - ./sites:/etc/nginx/conf.d:ro php-fpm: image: php:fpm ports: - 9000:9000 volumes: - /home/konrad/Workspace:/usr/share/www - ./conf/www.conf:/etc/php/7.0/fpm/pool.d/www.conf - ./conf/php.ini:/usr/local/etc/php/conf.d/90-php.ini:ro 

在远程服务器上,文件是可访问的,可见为1001:1001的属性