title: Nginx not serving static files with docker-compose and django (13: Permission denied)
body: <p>I'm using docker-compose and docker-machine to setup a dev environment with multiple containers. I have a container for nginx, which acts as a proxy to my django application and also serves static files). I have also a container for the django app, one for postgresql and one for postgresdata.
  The directory structure is the following:</p>
  
  <pre><code>code/
    -- nginx/
         Dockerfile
         nginx.conf
    -- web/
         django-project/
         static/
         Dockerfile
         manage.py
         requirements.txt
    .env
    docker-compose.yml
    production.yml
  </code></pre>
  
  <p>In order to run the application, I use docker-machine:</p>
  
  <pre><code>docker-machine create -d virtualbox dev
  </code></pre>
  
  <p>then I run:</p>
  
  <pre><code>docker-compose build
  docker-compose up -d
  </code></pre>
  
  <p>And the application is up and running on the ip of the machine. The problemm is that nginx cannot serve static files, because it hasn't the permission (13: Permission denied).</p>
  
  <p>My setup is the following:</p>
  
  <p>nginx Dockerfile:</p>
  
  <pre><code># Set nginx base image
  FROM nginx
  
  # Copy custom configuration file from the current directory
  COPY nginx.conf /etc/nginx/nginx.conf
  </code></pre>
  
  <p>nginx.conf:</p>
  
  <pre><code>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;
          }
      }
  }
  </code></pre>
  
  <p>django Dockerfile:</p>
  
  <pre><code>FROM python:3.5.1-onbuild
  </code></pre>
  
  <p>docker-compose.yml:</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>Versions:</p>
  
  <pre><code>docker: 1.9.1
  docker-compose: 1.5.2
  docker-machine: 0.5.4
  </code></pre>
  
  <p>Any help with this problem would be highly appreciated, thanks!</p>