Normally if multiple contains are to communicate with each other, they need to be on the same Docker Network, which looks something like this:
@Container
public static MicroProfileApplication<?> app = new MicroProfileApplication<>()
.withNetwork(Network.SHARED)
// ...
@Container
public static MockServerContainer mockServer = new MockServerContainer()
.withNetwork(Network.SHARED)
// ...
@Container
public static GenericContainer<?> mongo = new GenericContainer<>("mongo:3.4")
.withNetwork(Network.SHARED)
// ...
This can be non-obvious for new users, and typically if multiple containers are defined in the same class, it is reasonable to expect that they may need to communicate with each other. Or at least, not be an issue if they are able to communicate with each other.
This PR eliminates boiler plate by placing all containers on the Network.SHARED network if no networks are explicitly defined on any of the containers. Simplifying the above code example to:
@Container
public static MicroProfileApplication<?> app = new MicroProfileApplication<>()
// ...
@Container
public static MockServerContainer mockServer = new MockServerContainer()
// ...
@Container
public static GenericContainer<?> mongo = new GenericContainer<>("mongo:3.4")
// ...
Normally if multiple contains are to communicate with each other, they need to be on the same Docker
Network
, which looks something like this:This can be non-obvious for new users, and typically if multiple containers are defined in the same class, it is reasonable to expect that they may need to communicate with each other. Or at least, not be an issue if they are able to communicate with each other.
This PR eliminates boiler plate by placing all containers on the
Network.SHARED
network if no networks are explicitly defined on any of the containers. Simplifying the above code example to: