public void Pulls_runs_stops_image() { var client = new DockerClient(); client.PullImage("ubuntu"); var containerName = "lcldckr-test-container"; var id = client.RunImage("ubuntu", "latest", new RunArguments { Name = containerName, Interactive = true }); Assert.NotNull(id); var runningContainer = client .Ps(true, new[] { new NameFilter(containerName) }) .SingleOrDefault(); Assert.NotNull(runningContainer); Assert.Equal(containerName, runningContainer.Names.Single()); Assert.Equal(id.Substring(0, 12), runningContainer.ContainerId); id = client.StopContainer(containerName); Assert.NotNull(id); id = client.RemoveContainer(containerName); Assert.NotNull(id); }
public void Force_remove() { var client = new DockerClient(); client.PullImage("ubuntu"); var containerName = "lcldckr-test-container"; var id = client.RunImage("ubuntu", "latest", new RunArguments { Name = containerName, Interactive = true }); Assert.NotNull(id); id = client.RemoveContainer(containerName, force: true); Assert.NotNull(id); }
public void Builds_and_runs_container() { var client = new DockerClient(); var contextPath = AppContext.BaseDirectory; var dockerFilePath = Path.Combine(contextPath, "Dockerfile"); var imageId = client.Build(contextPath, dockerFilePath); var containerName = "lcldckr-build-test"; client.RunImage(imageId, containerName); var container = client .Ps(true, new[] { new NameFilter(containerName) }) .SingleOrDefault(); Assert.NotNull(container); client.StopAndRemoveContainer(containerName); }