i have a symfony environment running on a docker setup. Via docker-compose.yml (version 2) I start several containers. Following containers a relevant here:
phpfpm, nginx and mariadb
If i open my symfony project via browser it successfully connects to my database (on container called "mariadb"). Records from tables in my database are displayed. Even if i execute console commands to update my database schema it will work and changes are applied to my database.
Now i want to write functional / integration tests that run test against a second database on the same host (mariadb).
This is how i try to connect:
$dsn = sprintf(
'mysql:host=%s;port=%s',
'mariadb',
3306
);
$pdo = new PDOConnection(
$dsn,
'otk_dbuser',
'testpass'
);
But the result is the following message:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
/opt/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47
/opt/project/src/TestingBundle/Tests/DatabaseTestCase.php:56
/opt/project/src/TestingBundle/Tests/DatabaseTestCase.php:18
Could you please give me some help?
Kind regards, Max
Forget what i just asked. I executed my functional test within PHPStorm. PHPStorm uses therefore a standalone docker container, that has nothing todo with my docker-compose setup.
Dumb me!