title: Bug symfony docker and phpunit
body: <p>I have a problem for a week, my tests can not connect with the database.
  Indeed I have passed my environment under docker, my database connects perfectly but not the tests. Do you know why?
  My errors :</p>
  <pre><code>[critical] Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionException: &quot;An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for database failed: Name or service not known&quot; at /opt/project/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php line 103
  </code></pre>
  <p>Here are my files:</p>
  <p>docker-compose.yml</p>
  <pre><code>version: '3.7'
  services:
      database:
          image: 'mysql:5.7'
          environment:
              MYSQL_ROOT_PASSWORD: root
              MYSQL_DATABASE: app
          ports:
              - '3306:3306'
          volumes:
              - db-data:/var/lib/mysql/data:rw
  
      app:
          image: peedro07/app:latest
          ports:
            - &quot;8080:80&quot;
          environment:
            DATABASE_URL: mysql://root:root@database:3306/app
  
  volumes:
      db-data:
  </code></pre>
  <p>My Dockerfile which is build with the docker build command  . -f chemin/Dockerfile -t peedro07/app</p>
  <pre><code>FROM php:8.1-apache
  
  ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
  
  RUN chmod +x /usr/local/bin/install-php-extensions &amp;&amp; \
      install-php-extensions pdo_mysql intl
  
  RUN curl -sSk https://getcomposer.org/installer | php -- --disable-tls &amp;&amp; \
     mv composer.phar /usr/local/bin/composer
  
  
  COPY . /var/www/
  
  COPY ./docker/php/apache.conf /etc/apache2/sites-available/000-default.conf
  
  RUN cd /var/www &amp;&amp; \
      composer install
  
  WORKDIR /var/www/
  
  #ENTRYPOINT [&quot;bash&quot;, &quot;./docker/docker.sh&quot;]
  
  EXPOSE 80
  </code></pre>
  <p>My phpunit.xml.dist</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  
  &lt;!-- https://phpunit.readthedocs.io/en/latest/configuration.html --&gt;
  &lt;phpunit xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:noNamespaceSchemaLocation=&quot;vendor/phpunit/phpunit/phpunit.xsd&quot;
           backupGlobals=&quot;false&quot;
           colors=&quot;true&quot;
           bootstrap=&quot;tests/bootstrap.php&quot;
           convertDeprecationsToExceptions=&quot;false&quot;
  &gt;
      &lt;php&gt;
          &lt;env name=&quot;SYMFONY_DEPRECATIONS_HELPER&quot; value=&quot;weak&quot;/&gt;
          &lt;ini name=&quot;display_errors&quot; value=&quot;1&quot;/&gt;
          &lt;ini name=&quot;error_reporting&quot; value=&quot;-1&quot;/&gt;
          &lt;server name=&quot;APP_ENV&quot; value=&quot;test&quot; force=&quot;true&quot;/&gt;
          &lt;server name=&quot;SHELL_VERBOSITY&quot; value=&quot;-1&quot;/&gt;
          &lt;server name=&quot;SYMFONY_PHPUNIT_REMOVE&quot; value=&quot;&quot;/&gt;
          &lt;server name=&quot;SYMFONY_PHPUNIT_VERSION&quot; value=&quot;9.5&quot;/&gt;
      &lt;/php&gt;
  
      &lt;testsuites&gt;
          &lt;testsuite name=&quot;Project Test Suite&quot;&gt;
              &lt;directory&gt;tests&lt;/directory&gt;
          &lt;/testsuite&gt;
      &lt;/testsuites&gt;
  
      &lt;coverage processUncoveredFiles=&quot;true&quot;&gt;
          &lt;include&gt;
              &lt;directory suffix=&quot;.php&quot;&gt;src&lt;/directory&gt;
          &lt;/include&gt;
      &lt;/coverage&gt;
  
      &lt;listeners&gt;
          &lt;listener class=&quot;Symfony\Bridge\PhpUnit\SymfonyTestsListener&quot;/&gt;
      &lt;/listeners&gt;
  
      &lt;!-- Run `composer require symfony/panther` before enabling this extension --&gt;
      &lt;!--
      &lt;extensions&gt;
          &lt;extension class=&quot;Symfony\Component\Panther\ServerExtension&quot; /&gt;
      &lt;/extensions&gt;
      --&gt;
  
      &lt;extensions&gt;
          &lt;extension class=&quot;DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension&quot;/&gt;
      &lt;/extensions&gt;
  &lt;/phpunit&gt;
  </code></pre>
  <p>In my .env :</p>
  <pre><code>DATABASE_URL=&quot;mysql://root:root@database:3306/app&quot;
  </code></pre>
  <p>In my env.test</p>
  <pre><code>KERNEL_CLASS='App\Kernel'
  APP_SECRET='$ecretf0rt3st'
  SYMFONY_DEPRECATIONS_HELPER=999999
  PANTHER_APP_ENV=panther
  PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
  DATABASE_URL=&quot;mysql://root:root@database:3306/app&quot;
  </code></pre>