feat: Add network context manager
This PR adds a Network helper class that allows to create networks and connect containers programmatically.
The networks are context-managed resources like containers created via DockerContainer.
Please also see tests for a usage example :)
I'm interested in this feature. But I see progress has been dropped. Is there a reason?
I'm interested in this feature. But I see progress has been dropped. Is there a reason?
The build is failing due to https://github.com/cython/cython/issues/4568
I created #376 to fix it, but it hasn't been approved yet.
Hey @mloesch, thanks for providing this PR for the feature. I see you decided to allow specifying a name for the Network. In Testcontainers for Java, we made the design decision to only generate networks with random names, to avoid the potential for naming conflicts with existing networks. This is a general design approach of Testcontainers and it should be fine for the Testcontainers use cases.
Would you like to adapt the implementation accordingly?
See https://github.com/testcontainers/testcontainers-java/blob/1a3b23385f9a595576246a4c7f5dc54d244dd69d/core/src/main/java/org/testcontainers/containers/Network.java for the Java implementation.
Hey @kiview, thanks for the review, I changed the implementation to use random names in c10223fbec1d88755816c0ba9d2f77693816d822
@kiview is there anything else required for this PR to be merged? :)
Thank you for this @mloesch! 🙌 Really appreciate your contribution, this will benefit a lot of users 💯