public void InspectRunningContainerShallSucceed() { string id = null; try { var cmd = _docker.Run("nginx:1.13.6-alpine", null, _certificates); Assert.IsTrue(cmd.Success); id = cmd.Data; Assert.IsTrue(!string.IsNullOrWhiteSpace(id)); Assert.AreEqual(64, id.Length); var inspect = _docker.InspectContainer(id, _certificates); Assert.IsTrue(inspect.Success); Assert.IsTrue(inspect.Data.Name.Length > 2); Assert.AreEqual(true, inspect.Data.State.Running); } finally { if (null != id) { _docker.RemoveContainer(id, true, true, null, _certificates); } } }
public void UseNetworkAndStaticIpv4ShallWork() { string container = null; try { var cmd = _docker.Run("postgres:9.6-alpine", new ContainerCreateParams { PortMappings = new[] { "40001:5432" }, Environment = new[] { "POSTGRES_PASSWORD=mysecretpassword" }, Network = "mynetwork", Ipv4 = "1.1.1.1" }, _certificates); Assert.IsTrue(cmd.Success); container = cmd.Data; var insp = _docker.InspectContainer(container, _certificates); Assert.IsTrue(insp.Success); var ip = insp.Data.NetworkSettings.IPAddress; Assert.AreEqual("1.1.1.1", ip); } finally { if (null != container) { _docker.RemoveContainer(container, true, true); } } }
public Container GetConfiguration(bool fresh = false) { if (!fresh && null != _containerConfigCache) { return(_containerConfigCache); } _containerConfigCache = DockerHost.InspectContainer(Id, _certificates).Data; return(_containerConfigCache); }
public void LogsFromContaierWhenNotFollowModeShallExitByItself() { string id = null; try { var cmd = _docker.Run("postgres:9.6-alpine", new ContainerCreateParams { PortMappings = new[] { "40001:5432" }, Environment = new[] { "POSTGRES_PASSWORD=mysecretpassword" } }, _certificates); id = cmd.Data; var config = _docker.InspectContainer(id, _certificates); var endpoint = config.Data.NetworkSettings.Ports.ToHostPort("5432/tcp", _docker); endpoint.WaitForPort(10000 /*10s*/); using (var logs = _docker.Logs(id)) { while (!logs.IsFinished) { var line = logs.TryRead(5000); if (null == line) { Assert.AreEqual(true, logs.IsFinished, "Since null line, the process shall been shutdown"); break; } Debug.WriteLine(line); } Assert.AreEqual(true, logs.IsFinished); Assert.AreEqual(true, logs.IsSuccess); } } finally { if (null != id) { _docker.RemoveContainer(id, true, true, null, _certificates); } } }
public void UseNetworkAndStaticIpv4ShallWork() { string container = null; string id = null; try { var created = _docker.NetworkCreate("unit-test-nw", new NetworkCreateParams { Subnet = new [] { "10.18.0.0/16" } }, _certificates); Assert.IsTrue(created.Success); id = created.Data[0]; var cmd = _docker.Run("postgres:9.6-alpine", new ContainerCreateParams { PortMappings = new[] { "40001:5432" }, Environment = new[] { "POSTGRES_PASSWORD=mysecretpassword" }, Network = "unit-test-nw", Ipv4 = "10.18.0.22" }, _certificates); Assert.IsTrue(cmd.Success); container = cmd.Data; var insp = _docker.InspectContainer(container, _certificates); Assert.IsTrue(insp.Success); var ip = insp.Data.NetworkSettings.Networks["unit-test-nw"].IPAddress; Assert.AreEqual("10.18.0.22", ip); } finally { if (null != container) { _docker.RemoveContainer(container, true, true); } if (null != id) { _docker.NetworkRm(network: id); } } }