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 CreateAndDeleteContainerTest() { var svc = new WindowsDockerService(_services); var param = new ContainerCreateParameters("docker.io/kvnadig/rtvs-linux", "latest"); var container = await svc.CreateContainerAsync(param, CancellationToken.None); var container2 = await svc.GetContainerAsync(container.Id, CancellationToken.None); container.Id.Should().Be(container2.Id); await svc.DeleteContainerAsync(container.Id, CancellationToken.None); var containers = await svc.ListContainersAsync(true, CancellationToken.None); containers.Should().NotContain(c => c.Id == container.Id); }
public async Task BuildImageTest() { var dockerFileContent = @"FROM ubuntu:16.10 RUN apt-get update && apt-get upgrade -y"; var tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempDirectory); var dockerFile = Path.Combine(tempDirectory, "Dockerfile"); File.WriteAllText(dockerFile, dockerFileContent); var svc = new WindowsDockerService(_services); var param = new BuildImageParameters(dockerFile, "rtvs-test-build-image", "latest"); (await svc.BuildImageAsync(param, CancellationToken.None)).Should().BeTrue(); Directory.Delete(tempDirectory, true); }
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); }