public async Task CleanImageDownloadTest() { var svc = new WindowsDockerService(_services); var param = new ContainerCreateParameters("hello-world", "latest"); string imageName = $"{param.Image}:{param.Tag}"; await DeleteImageAsync(imageName); var images = await svc.ListImagesAsync(false, CancellationToken.None); images.Should().NotContain(c => c.Name == param.Image && c.Tag == param.Tag); var container = await svc.CreateContainerAsync(param, CancellationToken.None); await svc.StartContainerAsync(container.Id, CancellationToken.None); var images2 = await svc.ListImagesAsync(false, CancellationToken.None); images2.Should().Contain(c => c.Name == param.Image && c.Tag == param.Tag); await svc.StopContainerAsync(container.Id, CancellationToken.None); await svc.DeleteContainerAsync(container.Id, CancellationToken.None); var allContainers = await svc.ListContainersAsync(true, CancellationToken.None); allContainers.Should().NotContain(c => c.Id == container.Id); await DeleteImageAsync(imageName); }
public async Task StartStopContainerTest() { var svc = new WindowsDockerService(_services); var param = new ContainerCreateParameters("docker.io/kvnadig/rtvs-linux", "latest"); var container = await svc.CreateContainerAsync(param, CancellationToken.None); await svc.StartContainerAsync(container.Id, CancellationToken.None); var runningContainers = await svc.ListContainersAsync(false, CancellationToken.None); runningContainers.Should().Contain(c => c.Id == container.Id); await svc.StopContainerAsync(container.Id, CancellationToken.None); var runningContainers2 = await svc.ListContainersAsync(false, CancellationToken.None); runningContainers2.Should().NotContain(c => c.Id == container.Id); await svc.DeleteContainerAsync(container.Id, CancellationToken.None); var allContainers = await svc.ListContainersAsync(true, CancellationToken.None); allContainers.Should().NotContain(c => c.Id == container.Id); }