MySQLContainer Random Port
benkio opened this issue · comments
Hi,
I write because, while trying to set up an Integration test with MySQLContainer
, I noticed the port used is always random instead of the standard 3306
. I attach a screenshot, in this case the random port assigned is 55040
, here is the link to the code:
Thanks in advance
I've just found a workaround by dynamically setting the DB Port via Environment Variable:
benkio/myTelegramBot@67b5758
@benkio it's not a bug, it's an intended behavior: https://www.testcontainers.org/features/networking/
From the host's perspective Testcontainers actually exposes this on a random free port. This is by design, to avoid port collisions that may arise with locally running software or in between parallel test runs.
Then I guess my solution is not actually a workaround, but rather the way to go.
I Close the issue