title: Database connection issue through docker containers
body: <p>I have set up a dev environment with Symfony and MariaDB through docker.</p>
  
  <p>I've taken the bitman/symfony image there : </p>
  
  <pre><code> https://hub.docker.com/r/bitnami/symfony
  </code></pre>
  
  <p>This is my <strong>docker-compose.yaml</strong></p>
  
  <pre><code>version: '2'
  
  services:
    myapp:
      image: 'bitnami/symfony:1'
      ports:
        - '8000:8000'
      volumes:
        - '.:/app'
      environment:
        - SYMFONY_PROJECT_NAME=backend
        - MARIADB_PORT_NUMBER=3306
        - MARIADB_USER=root
      container_name: symfony_container
      depends_on:
        - mariadb
    mariadb:
      image: 'bitnami/mariadb:10.3'
      ports:
        - '3306:3306'
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=root
    container_name: mariadb_container
  </code></pre>
  
  <p>Important line in <strong>.env file</strong> :</p>
  
  <pre><code>DATABASE_URL=mysql://root:@localhost:3306/
  </code></pre>
  
  <p>My <strong>doctrine.yaml</strong> file:</p>
  
  <pre><code>doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'
        server_version: '5.7'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App
  </code></pre>
  
  <p>Now if I run <strong>docker-compose up</strong>, both containers start and I can access Symfony.</p>
  
  <p>BUT if I try to create an entity with :</p>
  
  <pre><code>php bin/console make:entity
  </code></pre>
  
  <p>I get the four following errors : </p>
  
  <pre><code>An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
  
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution 
  
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution  
  
  PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution 
  </code></pre>
  
  <p>The strange thing is that I can access MariaDB database through dbeaver without trouble. It seems as if the Symfony container did not manage to find the MariaDB container.</p>
  
  <p>I'll precise that I use symfony version 5.0.4</p>
  
  <p>If anyone knows where those errors come from I'll be grateful</p>