testcontainers-rs icon indicating copy to clipboard operation
testcontainers-rs copied to clipboard

add possibility to start container in host network

Open pronvis opened this issue 4 years ago • 3 comments

pronvis avatar Sep 04 '20 16:09 pronvis

PR

pronvis avatar Sep 04 '20 16:09 pronvis

I'm in a situation where I'm running my CI inside of docker, and have bind-mounted the host docker daemon's socket so that I can create sibling containers instead of using docker-in-docker (doing things via a remote docker daemon in this fashion appears to be the recommended approach). This means that when testcontainers creates a container, it makes that container a sibling to the currently executing CI container, rather than a child container. As a result, I cannot access the new container via localhost:1234, since sibling containers don't share a docker network by default.

My understanding is that the correct approach to address this is to create a docker network and assign it to both the CI container and the sibling container that testcontainers creates. Would #202 or a similar PR address this use case?

TheButlah avatar Sep 11 '20 22:09 TheButlah

The network approach should work but I think the real solution would be something like this: https://github.com/testcontainers/testcontainers-rs/pull/141

That issue pretty much stalled unfortunately. The feature is not a priority for us so I can't really allocate much time to it :/ However, like I said in the linked PR, I am more than happy for this to be realized but it would need someone else to push it forward :)

thomaseizinger avatar Sep 14 '20 08:09 thomaseizinger

Oh damn...I would really like this...so I can test TiKV database.

0xDjole avatar Apr 13 '24 22:04 0xDjole

Since it's already possible to start container in host network, I'm going to close the issue.

Regarding the approach discussed here for running tests in a container - this should generally be possible, for example we check this to get the host

But this is a question for a separate issue, in which you need to determine the limitations and scope of work if necessary

DDtKey avatar May 09 '24 19:05 DDtKey