diff --git a/core/src/test/java/org/testcontainers/containers/NetworkTest.java b/core/src/test/java/org/testcontainers/containers/NetworkTest.java index 04edf42c6d1..b717b8dc81a 100644 --- a/core/src/test/java/org/testcontainers/containers/NetworkTest.java +++ b/core/src/test/java/org/testcontainers/containers/NetworkTest.java @@ -5,6 +5,7 @@ import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import org.testcontainers.DockerClientFactory; +import org.testcontainers.containers.Network; import static org.rnorth.visibleassertions.VisibleAssertions.*; import static org.testcontainers.containers.Network.newNetwork; @@ -39,8 +40,9 @@ public static class WithoutRules { @Test public void testNetworkSupport() throws Exception { + // useCustomNetwork { try ( - Network network = newNetwork(); + Network network = Network.newNetwork(); GenericContainer foo = new GenericContainer() .withNetwork(network) @@ -57,6 +59,7 @@ public void testNetworkSupport() throws Exception { String response = bar.execInContainer("wget", "-O", "-", "http://foo:8080").getStdout(); assertEquals("received response", "yay", response); } + // } } @Test diff --git a/docs/features/networking.md b/docs/features/networking.md index d0007df878b..75dd924d6bc 100644 --- a/docs/features/networking.md +++ b/docs/features/networking.md @@ -75,3 +75,15 @@ For example, here we construct an HTTP URL for our local web application and tel [Accessing the exposed host port from a container](../examples/src/test/java/generic/HostPortExposedTest.java) inside_block:useHostExposedPort + + +## Advanced networking + +Docker provides the ability for you to create custom networks and place containers on one or more networks. Then, communication can occur between networked containers without the need of exposing ports through the host. With Testcontainers, you can do this as well. + +!!! warning + Note that Testcontainers currently only allows a container to be on a single network. + + +[Creating custom networks](../../core/src/test/java/org/testcontainers/containers/NetworkTest.java) inside_block:useCustomNetwork + \ No newline at end of file