不使用docker-compose和django提供静态文件的Nginx(13:权限被拒绝)

我使用docker-compose和docker-machine来设置具有多个容器的开发环境。 我有一个nginx的容器,它作为我的django应用程序的代理,也提供静态文件)。 我也有一个django应用程序的容器,一个用于postgresql,一个用于postgresdata。 目录结构如下:

code/ -- nginx/ Dockerfile nginx.conf -- web/ django-project/ static/ Dockerfile manage.py requirements.txt .env docker-compose.yml production.yml 

为了运行应用程序,我使用docker-machine:

 docker-machine create -d virtualbox dev 

然后我运行:

 docker-compose build docker-compose up -d 

而应用程序已经启动并在机器的ip上运行。 问题是nginx无法提供静态文件,因为它没有权限(13:权限被拒绝)。

我的设置如下:

nginx Dockerfile:

 # Set nginx base image FROM nginx # Copy custom configuration file from the current directory COPY nginx.conf /etc/nginx/nginx.conf 

ngin.conf:

 worker_processes 1; events { worker_connections 1024; } http { server { listen 80; server_name example.org; access_log /dev/stdout; error_log /dev/stdout info; location /static/ { alias /usr/src/app/static/; } location / { proxy_pass http://web:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } } } 

django Dockerfile:

 FROM python:3.5.1-onbuild 

泊坞窗,compose.yml:

 web: restart: always build: ./web expose: - "8000" links: - postgres:postgres volumes: - /usr/src/app/static env_file: .env command: /usr/local/bin/gunicorn collecteev_django.wsgi:application -w 2 -b :8000 nginx: restart: always build: ./nginx/ ports: - "80:80" volumes_from: - web links: - web:web postgres: restart: always image: postgres:latest volumes_from: - data ports: - "5432:5432" data: restart: always image: postgres:latest volumes: - /var/lib/postgresql command: "true" 

版本:

 docker: 1.9.1 docker-compose: 1.5.2 docker-machine: 0.5.4 

任何帮助这个问题将不胜感激,谢谢!