public void MultipleUseNetworkWithSameAliasShallWorkWithString() { using (var nw1 = _host.CreateNetwork("unit-test-network-1", removeOnDispose: true)) using (var nw2 = _host.CreateNetwork("unit-test-network-2", removeOnDispose: true)) { var alias = "hello"; var testerImageName = $"hello-world-tester"; var helloContainerBuilder = new Builders.Builder().UseContainer() .UseImage("crccheck/hello-world") .UseNetworksWithAlias(alias, nw1.Name, nw2.Name); var testerImageBuilder = new Builders.Builder().DefineImage(testerImageName) .From("alpine") .Run( "apk add curl" ) .Command( "curl", $"http://{alias}:8000" ); var testerContainerBuilder1 = new Builders.Builder().UseContainer() .UseNetwork(nw1) .UseImage(testerImageName); var testerContainerBuilder2 = new Builders.Builder().UseContainer() .UseNetwork(nw2) .UseImage(testerImageName); using (var helloContainer = helloContainerBuilder.Build()) using (var testerImage = testerImageBuilder.Build()) using (var testerContainer1 = testerContainerBuilder1.Build()) using (var testerContainer2 = testerContainerBuilder2.Build()) { helloContainer.Start(); testerContainer1.Start(); var logsAlias1 = string.Join( "\n", testerContainer1.DockerHost.Logs(testerContainer1.Id).ReadToEnd()); Assert.IsTrue(logsAlias1.IndexOf("Hello World") >= 0); testerContainer2.Start(); var logsAlias2 = string.Join( "\n", testerContainer2.DockerHost.Logs(testerContainer2.Id).ReadToEnd()); Assert.IsTrue(logsAlias2.IndexOf("Hello World") >= 0); } } }
public void AttachWithAliasShallWorkWithIContainerService() { using (var nw = _host.CreateNetwork("unit-test-network", removeOnDispose: true)) { var alias = "hello"; var testerImageName = "hello-world-tester"; var helloContainerBuilder = new Builders.Builder().UseContainer() .UseImage("crccheck/hello-world"); var testerImageBuilder = new Builders.Builder().DefineImage(testerImageName) .From("alpine") .Run( "apk add curl" ) .Command( "curl", $"http://{alias}:8000" ); var testerContainerBuilder = new Builders.Builder().UseContainer() .UseNetwork(nw) .UseImage(testerImageName); using (var helloContainer = helloContainerBuilder.Build()) using (var testerImage = testerImageBuilder.Build()) using (var testerContainer = testerContainerBuilder.Build()) { helloContainer.Start(); nw.Attach(helloContainer, true, alias); testerContainer.Start(); var logs = string.Join( "\n", testerContainer.DockerHost.Logs(testerContainer.Id).ReadToEnd()); Assert.IsTrue(logs.IndexOf("Hello World") >= 0); } } }
public void Master() { // Use the alias Builders.Builder bob = new Builders.Builder(); bob.Build(); }