title: Why can't I connect to my local docker-compose container on Windows 10?
body: <p>I'm trying to dockerize a Python application, for which I've been following <a href="https://realpython.com/blog/python/dockerizing-flask-with-compose-and-machine-from-localhost-to-the-cloud/" rel="noreferrer">this tutorial</a>. The tutorial is from April 2015 and still uses Docker Machine, which, judging from <a href="https://stackoverflow.com/a/38624540/1814949">this answer</a>, is no longer necessary to run Docker containers locally on Windows.</p>
  
  <p>I got it working with Docker Machine before, and was able to see the web app and interact with it. But now I'm trying to get this working without Docker Machine, with Docker version 17.06.0-ce, build 02c1d87, on Windows 10.</p>
  
  <p>Here's the <code>docker-compose.yml</code>:</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 -w 2 -b :8000 app:app
  
  nginx:
    restart: always
    build: ./nginx/
    ports:
      - "80:80"
    volumes:
      - /www/static
    volumes_from:
      - web
    links:
      - web:web
  
  data:
    image: postgres:latest
    volumes:
      - /var/lib/postgresql
    command: "true"
  
  postgres:
    restart: always
    image: postgres:latest
    volumes_from:
      - data
    ports:
      - "5432:5432"
  </code></pre>
  
  <p>I started the containers:</p>
  
  <pre><code>$ docker-compose up -d
  Creating polly_data_1 ...
  Creating polly_data_1 ... done
  Creating polly_postgres_1 ...
  Creating polly_postgres_1 ... done
  Creating polly_web_1 ...
  Creating polly_web_1 ... done
  Creating polly_nginx_1 ...
  Creating polly_nginx_1 ... done
  </code></pre>
  
  <p>Then, when I run <code>docker ps</code>, it shows the following three containers running:</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
  9b2c1048f3a5        polly_nginx         "/usr/sbin/nginx"        4 seconds ago       Up 3 seconds        0.0.0.0:80-&gt;80/tcp       polly_nginx_1
  d561ac5b901a        polly_web           "/usr/local/bin/gu..."   5 seconds ago       Up 4 seconds        8000/tcp                 polly_web_1
  ecb029d6ec3a        postgres:latest     "docker-entrypoint..."   7 seconds ago       Up 5 seconds        0.0.0.0:5432-&gt;5432/tcp   polly_postgres_1
  </code></pre>
  
  <p>(At this point, navigating to <code>http://localhost:8000/</code> in Chrome already yields <code>ERR_CONNECTION_REFUSED</code>.)</p>
  
  <p>I then ran the script to set up the database, as per the tutorial (extra <code>//</code>s because I'm using Git Bash on Windows 10):</p>
  
  <pre><code>$ docker-compose run web ///usr/local/bin/python create_db.py
  Starting polly_data_1 ...
  Starting polly_data_1 ... done
  Starting polly_postgres_1 ... done
  </code></pre>
  
  <p>Now when I run <code>docker ps</code>, it shows the following four containers running:</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                  PORTS                    NAMES
  a129c12f5982        polly_web           "//usr/local/bin/p..."   5 seconds ago       Up Less than a second   8000/tcp                 polly_web_run_1
  9b2c1048f3a5        polly_nginx         "/usr/sbin/nginx"        16 seconds ago      Up 15 seconds           0.0.0.0:80-&gt;80/tcp       polly_nginx_1
  d561ac5b901a        polly_web           "/usr/local/bin/gu..."   17 seconds ago      Up 16 seconds           8000/tcp                 polly_web_1
  ecb029d6ec3a        postgres:latest     "docker-entrypoint..."   19 seconds ago      Up 17 seconds           0.0.0.0:5432-&gt;5432/tcp   polly_postgres_1
  </code></pre>
  
  <p>And <code>localhost:8000</code> is still refusing to connect. The web container exposes port 8000, so I don't get why I can't connect to it.</p>
  
  <p>How can I get this working so I can access the web app in the <code>web</code> container locally?</p>