withNetwork method
Puts the container on network, where the other containers of it
reach this one by its withNetworkAliases names and the ports it
listens on. The network is created when the first container on it
starts.
final network = Network.newNetwork();
final database = PostgresContainer()
.withNetwork(network)
.withNetworkAliases(['db']);
Testcontainers (Java): withNetwork(network).
Implementation
GenericContainer withNetwork(Network network) {
_network = network;
return this;
}