title: Cannot connect Lumen with PostgreSQL on Docker
body: <p>I have Lumen with PostgreSQL dockerized with docker-compose. Both works like a charm but I cannot make a migration or insert data because Lumen container is not connected to the PostgreSQL one, it appears the following error: </p>
  
  <blockquote>
    <p>SQLSTATE[08006] [7] could not connect to server: Connection refused.Is
    the server running on host "postgresql" (172.18.0.3) and accepting
    TCP/IP connections on port 9906?</p>
  </blockquote>
  
  <p>Dockerfile</p>
  
  <pre><code>FROM php:7-apache
  
  RUN apt-get upgrade -y \
      &amp;&amp; apt-get update -y \
      &amp;&amp; apt-get install git-core libzip-dev openssl unzip zip libpq-dev postgresql-client -y \
      &amp;&amp; apt-get clean \
      &amp;&amp; docker-php-ext-install mbstring pdo pdo_pgsql pgsql
  
  # Apache Config
  ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
  RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
  RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
  RUN a2enmod rewrite
  
  # Composer
  RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  
  WORKDIR /var/www/html
  
  EXPOSE 8100
  </code></pre>
  
  <p>docker-compose.yml</p>
  
  <pre><code>version: '3.5'
  services:
    app:
      build: .
      container_name: form_app
      depends_on:
      - postgresql
      ports:
        - "8100:80"
      volumes:
        - .:/var/www/html/
      stdin_open: true
      tty: true
    postgresql:
      image: postgres
      restart: always
      container_name: form_pgsql
      environment:
        POSTGRES_USER: formularios
        POSTGRES_PASSWORD: formularios
        POSTGRES_DB: formularios
      ports:
        - "9906:5432"
      volumes:
        - pgdata:/var/lib/postgresql/data
    admin:
      image: adminer
      container_name: form_adminer
      ports:
      - "8880:8080"
  volumes:
    pgdata:
  </code></pre>
  
  <p>.env</p>
  
  <pre><code>APP_NAME=Lumen
  APP_ENV=local
  APP_KEY=feZh5izBbOLIek27RQip9ciwTdRHPV7R
  APP_DEBUG=true
  APP_URL=http://localhost:8100
  APP_TIMEZONE=UTC
  
  LOG_CHANNEL=stack
  LOG_SLACK_WEBHOOK_URL=
  
  DB_CONNECTION=pgsql
  DB_HOST=postgresql
  DB_PORT=9906
  DB_DATABASE=formularios
  DB_USERNAME=formularios
  DB_PASSWORD=formularios
  
  CACHE_DRIVER=file
  QUEUE_CONNECTION=sync
  </code></pre>