testcontainers / testcontainers-go

Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.
https://golang.testcontainers.org
MIT License
3.36k stars 460 forks source link

[Enhancement]: Allow network selection for modules (e.g. postgres) #2556

Open tomek-kontakt opened 2 months ago

tomek-kontakt commented 2 months ago

Proposal

Motivation When a sidecar service, such as a cron job or processor, operates in conjunction with a database, we would like the ability to attach both the service and the database to the same network. Currently, this option appears to be available only for generic containers.

Proposal Add another configuration option to options.go that enables setting the network (by name or by reference) and aliases. Alternatively, this feature could be introduced to selected modules as a module-specific configurer.

mdelapenya commented 1 month ago

Hi @tomek-kontakt thanks for reaching out. There are two functional options to configure the network, added in v0.27.0: https://golang.testcontainers.org/modules/postgres/#withnetwork

Is that what you need?