Skip to content

No host port mapping after creating container #3

@kursph

Description

@kursph

I noticed when creating a new MySQLContainer like so

protected function setUp(): void
{
      $this->container = MySQLContainer::make();
      $this->container->withMySQLDatabase('pimcore');
      $this->container->withMySQLUser('pimcore_user', 'pimcore');
      try {
          $this->container->run();
      } catch (JsonException $e) {
          $this->fail($e->getMessage());
      }
}

but when checking out the docker container with docker ps and docker inspect there is no port mapped to the host (localhost). And then when I try to connect to it like so

$this->pdo = new PDO(
      sprintf('mysql:host=%s;port=3306', $this->container->getAddress()),
      'pimcore_user',
      'pimcore',
);

host missing when inspecting the container

"Ports": {
      "3306/tcp": null,
      "33060/tcp": null
},

I get this timeout error

1) Tests\App\journey\ContactIntegrationTest::testGetAllAction
PDOException: SQLSTATE[HY000] [2002] Operation timed out

here the container in Docker Desktop
Bildschirm­foto 2023-12-21 um 11 05 05

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions