Closed lazystone closed 7 months ago
The way I have done these things in the past outside of testcontainers is to put all the containers on the same network and use container_name:internal_port
to allow them to talk to each other.
I am not sure if that would work or be useful for testcontainers though. Do you mind sharing a bit more what your usecase is?
I have a java background and started to play with Rust recently - I'm trying to reproduce very simple service in Rust.
One of the dependencies is Kafka, so I was trying to use testcontainers-rs to run zookeeper+kafka.
I guess there are a different of ways to access zookeeper container from Kafka:
NetworkSettings.IPAddress
(haven't tested that, but should work probably)docker network
and provide names for containersInteresting, thanks for sharing!
Before we make the IP address public, do you mind just forking the lib and try out if what you want to do works?
I am happy to expose NetworkSettings.IPAddress
if it turns out to enable that feature!
As far as I can see it was released. Closing the issue.
Right now it's possible to get mapped port via
get_host_port
method, and connect to services aslocalhost:<mapped port>
.It might be useful to implement
get_ip_address
method and returnNetworkSettings.IPAddress
fromdocker inspect <id>
, so it's possible to connect from one docker container to another using that IP.