title: Django Nginx Docker Gunicorn cant reach
body: <p>Sorry if it the answer seems obvious, but I've been bashing my head for the past couple of hours.</p>
  
  <p>I've been following multiple tutorials trying to dockerize my application. No matter what combination of url:port or just url I tried I can't access the pages. </p>
  
  <p>I have zero clue what am I doing wrong. I am assuming the following:</p>
  
  <ul>
  <li>NGINX config plain wrong. How can <code>upstream web</code> know what's <code>web</code>? I assume docker exposes it, but unsure whether this is correct.</li>
  <li>web container not exposing address and port properly?</li>
  </ul>
  
  <p>I tried multipled settings, but non work.</p>
  
  <p>I have the following:</p>
  
  <p><code>Dockerfile</code></p>
  
  <pre><code>FROM python:3
  ENV PYTHONUNBUFFERED 1
  RUN mkdir /code
  WORKDIR /code
  ADD requirements.txt /code/
  RUN pip install -r requirements.txt
  ADD . /code/
  ADD ./django.conf /etc/nginx/conf.d/default.conf
  
  #COPY ./django.conf /etc/nginx/sites-available/
  #RUN ln -s /etc/nginx/sites-available/django.conf /etc/nginx/sites-enabled
  </code></pre>
  
  <p><code>docker-compose.yml</code></p>
  
  <pre><code>version: '3'
  
  services:
    db:
      image: postgres:9.6
      ports:
       - "5432:5432"
      environment:
        - POSTGRES_USER=random_user
        - POSTGRES_PASSWORD=random_password
    redis:
      restart: always
      image: redis:4.0
      expose:
        - "6379"
  
    nginx:
      image: nginx:1.14.0
      container_name: nginx01
      ports:
        - "8000:8000"
      volumes:
        - ./code
      depends_on:
       - web
    web:
      build: .
      container_name: backend-api
      command: bash -c "python manage.py migrate &amp;&amp; python manage.py collectstatic --noinput &amp;&amp; gunicorn ops4_backend.wsgi -b 0.0.0.0:8000"
      depends_on:
        - db
      volumes:
        - ./code
      expose:
        - "8000"
      restart: always
  </code></pre>
  
  <p><code>django.conf</code></p>
  
  <pre><code>upstream web {
     ip_hash;
     server web:8000;
   }
  
   # portal
   server {
     location / {
          proxy_pass http://web:8000;
       }
     listen 8000;
     server_name localhost;
  
     location /static {
       autoindex on;
       alias /src/static/;
     }
   }
  </code></pre>
  
  <p><code>docker ps -a</code>
  <a href="https://i.stack.imgur.com/inCOy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/inCOy.png" alt="docker ps -a"></a></p>