title: Python application cannot connect to PostgreSQL Docker
body: <p>Can anyone help me on this?</p>
  
  <p><b>Dockerfile</b> for my image:</p>
  
  <pre><code>FROM python:3.6.1
  ENV PYTHONUNBUFFERED 1
  RUN mkdir /hlcup
  WORKDIR /hlcup
  ADD requirements.txt /hlcup/
  RUN pip install --upgrade pip
  RUN pip3 install -r requirements.txt
  ADD . /hlcup/
  EXPOSE 80
  EXPOSE 5432
  </code></pre>
  
  <p>My <b>docker-compose.yml</b>:</p>
  
  <pre><code>version: '3'
  
  services:
  db:
      image: postgres
      environment:
        POSTGRES_USER: ${POSTGRES_USER}
        POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
        POSTGRES_DB: ${POSTGRES_DB}
      ports:
        - "5432:5432"
    web:
      build: .
      command: python3 main.py
      volumes:
        - .:/hlcup
        - ./data:/tmp/data/
      ports:
        - "80:80"
      depends_on:
        - db    
  </code></pre>
  
  <p>I run my build: <b>docker-compose up --build</b> </p>
  
  <p>As a result, the application should connect to the database, but I get a connection error:</p>
  
  <pre><code>web_1  |     conn = await asyncpg.connect(**DB_PARAMS)
  web_1  |   File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 1688, in connect
  web_1  |     max_cacheable_statement_size=max_cacheable_statement_size)
  web_1  |   File "/usr/local/lib/python3.6/site-packages/asyncpg/connect_utils.py", line 551, in _connect
  web_1  |     raise last_error
  web_1  |   File "/usr/local/lib/python3.6/site-packages/asyncpg/connect_utils.py", line 543, in _connect
  web_1  |     connection_class=connection_class)
  web_1  |   File "/usr/local/lib/python3.6/site-packages/asyncpg/connect_utils.py", line 513, in _connect_addr
  web_1  |     connector, timeout=timeout, loop=loop)
  web_1  |   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
  web_1  |     return fut.result()
  web_1  |   File "/usr/local/lib/python3.6/asyncio/base_events.py", line 776, in create_connection
  web_1  |     raise exceptions[0]
  web_1  |   File "/usr/local/lib/python3.6/asyncio/base_events.py", line 763, in create_connection
  web_1  |     yield from self.sock_connect(sock, address)
  web_1  |   File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 451, in sock_connect
  web_1  |     return (yield from fut)
  web_1  |   File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 481, in _sock_connect_cb
  web_1  |     raise OSError(err, 'Connect call failed %s' % (address,))
  web_1  | ConnectionRefusedError: [Errno 111] Connect call failed ('0.0.0.0', 5432)
  </code></pre>