Skip to content

Database random port mapping does not work #386

@prochnowc

Description

@prochnowc

Describe the bug

When creating a eg. Postgres database container the random port mapping does not work.

To Reproduce
Steps to reproduce the behavior:

  await new TestcontainersBuilder<PostgreSqlTestcontainer>()
    .WithDatabase(
    new PostgreSqlTestcontainerConfiguration
    {
      Database = "test",
      Username = "user",
      Password = "password"
     })
     .Build()
     .StartAsync();

exposes some random port eg. 49132, but the actual port I can see in docker is different.
If I explicitly map the port it works.

Desktop (please complete the following information):

  • Version 3.3.3 with WSL2

Additional context

Dotnet.Testcontainers v1.5.0-beta.1928

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionHave you tried our Slack Workspace (https://testcontainers.slack.com)?

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions