testcontainers-node: getContainerIpAddress() does not work as expected in Gitlab CI docker runner
I have a similar issue like #7
I am starting two docker containers in my tests (postgres and rabbitMQ). Then I construct the connection strings using container.getContainerIpAddress() and container.getMappedPort(). Everything works locally. However, in Gitlab CI I get the following error.
Error: connect ECONNREFUSED 127.0.0.1:44937
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14)
When checking the value of getContainerIpAddress() it always returns localhost even when run in the Gitlab CI docker runner. While the Java counter part of testcontainers returns a real IP address like 172.17.0.1 in Gitlab CI.
Can you adjust your code to behave like your Java counter part?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18
Commits related to this issue
- #15 Set hostname as default gateway when running in container — committed to testcontainers/testcontainers-node by cristianrgreco 5 years ago
@KaiStapel Yes, it’s a major release because there’s a breaking change. If you have:
Then you just have to add
.build()at the end, asfromDockerfilenow returns a builder.