You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: getFirstMappedPort returns wrong port after adding secondary network #11779
Then, when I ask the mapped port with container.getFirstMappedPort(), the returned port is not usable. docker ps shows a mapped port which is +1 compared to getFirstMappedPort().
It looks like adding a network remaps the exposed port, but testcontainer somewhat cached the first value.
Starting with defaultNetwork and then adding my customNetwork fixes the issue for me regarding the port (I can connect from the host using the given port), but then I can't use the network alias from another container the customNetwork.
Hi, I'd like to work on this issue. I’m currently setting up the project locally and investigating the problem. Please let me know if anyone is already working on it.
Activity
idsoke commentedon May 28, 2026
Hi, I'd like to work on this issue. I’m currently setting up the project locally and investigating the problem. Please let me know if anyone is already working on it.
soumajitgh commentedon Jun 18, 2026
i looked into this, and it seems like testcontainers may be holding on to old port information after the container starts.
i am working on a pr for this.