testcontainers / testcontainers-rs

A library for integration-testing against docker containers from within Rust.
https://rust.testcontainers.org
Apache License 2.0
769 stars 141 forks source link

Expose `NetworkSettings.IPAddress` #188

Closed lazystone closed 7 months ago

lazystone commented 4 years ago

Right now it's possible to get mapped port via get_host_port method, and connect to services as localhost:<mapped port>.

It might be useful to implement get_ip_address method and return NetworkSettings.IPAddress from docker inspect <id>, so it's possible to connect from one docker container to another using that IP.

thomaseizinger commented 4 years 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?

lazystone commented 4 years ago

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:

thomaseizinger commented 4 years ago

Interesting, 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!

DDtKey commented 7 months ago

As far as I can see it was released. Closing the issue.