public void DockerPsWithOneContainerShallGiveOneResult() { 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 ls = _docker.Ps(null, _certificates); Assert.IsTrue(ls.Success); Assert.AreEqual(1, ls.Data.Count); Assert.IsTrue(id.StartsWith(ls.Data[0])); } finally { if (null != id) { _docker.RemoveContainer(id, true, true, null, _certificates); } } }
public static CommandResponse <IList <Container> > InspectContainers(this DockerUri host, ICertificatePaths certificates = null, params string[] containerIds) { if (containerIds?.Any() != true) { var psResult = host.Ps("--all", certificates); if (!psResult.Success) { return(new CommandResponse <IList <Container> >(psResult.Success, psResult.Log, psResult.Error)); } containerIds = psResult.Data.ToArray(); } var dockerBinary = "docker".ResolveBinary(); return(new ProcessExecutor <ClientInspectContainersResponseParser, IList <Container> >(dockerBinary, $"{host.RenderBaseArgs(certificates)} inspect " + string.Join(" ", containerIds)) .Execute()); }