title: Could not connect to Postgres from Symfony 4 + Docker
body: <p>I run into the strange problem. I've created docker-compose file to build php + nginx + postgres services:</p>
  
  <pre><code>version: '2'
  services:
      db:
          image: orchardup/postgresql
          ports:
              - "5433:5432"
          environment:
              LC_ALL: C.UTF-8
              POSTGRESQL_USER: postgres
              POSTGRESQL_DB:   db
              POSTGRESQL_PASS: postgres
  
      php:
          build: .docker/php-fpm
          ports:
              - "9002:9002"
          volumes:
              - .:/var/www/symfony:cached
              - ./var/log/symfony:/var/www/symfony/var/log:cached
          links:
              - db
  
      nginx:
          build: .docker/nginx
          ports:
              - "8001:80"
          links:
              - php
          volumes_from:
              - php
          volumes:
              - ./var/log/nginx/:/var/log/nginx:cached
  </code></pre>
  
  <p>After that I created DB schema by running <strong>bin/console doctrine:schema:update --force</strong> . The tables and migrations created just fine. Seems like DB connection is ok. I checked this by connecting to db from my machine through psql with credentials from <strong>.env</strong>, the tables are there.</p>
  
  <p>But when I go to the web page and trying to authorize, I get an error told me the connection is not ok:</p>
  
  <pre><code>Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5433?"
  </code></pre>
  
  <p>I checked in both case I have dev environment - from the web page and from the console. I tried 5433 and 5432 ports with no success. I tried everything I could find for 3 hours.</p>
  
  <p>This is the output from the postgres container:</p>
  
  <pre><code># netstat -tlpn | grep 5432
  (Not all processes could be identified, non-owned process info
   will not be shown, you would have to be root to see it all.)
  tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      12/postgres
  tcp6       0      0 :::5432                 :::*                    LISTEN      12/postgres
  
  # grep listen /etc/postgresql/9.3/main/postgresql.conf
  listen_addresses = '*'     # what IP address(es) to listen on;
  </code></pre>