Closed jhrcek closed 1 year ago
Thanks for raising the issue @jhrcek. The testcontainers-hs got revamped quite a bit with version 0.5.0.0. In particular, the philosophy of testcontainers is to isolate all the things and have automatic resource cleanup after. The general recommendation is to follow the isolation. But I am not opposed to adding the function that you proposed.
Let me open a PR and we can discuss over there.
Closing as resolved by https://github.com/testcontainers/testcontainers-hs/pull/41. Thanks for implementing my suggestion!
Hello @alexbiehl today I tried updating our tests to use testcontainers-0.5.0.0 and found out the new API has no easy way to specify --network without actually creating new network.
Till now we were using setNetwork added by my colleague in https://github.com/testcontainers/testcontainers-hs/pull/20
In 0.5.0.0 I see withNetwork function, but it requires value of type Network. Looking at source code it seems that the only way to create value of this (opaque) type is through createNetwork which calls
docker create
.But what if (as we're doing in CI) you want to connect to a network that was created for us outside of test logic? I'd still be like to run docker container using this library, connecting to such network. But in the current API there doesn't seem to be way to do that (unless I'm missing something).
What would you say to adding something like a following function to allow for this usecase?
Or if you want to be extra careful (verifying that network with such a name exists, you could call
docker network ls
ordocker network inspect
..