Пример #1
0
        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);
        }
Пример #2
0
 internal void cleanup()
 {
     Task.WaitAll(containers.Values.Map(x => docker.RemoveContainer(x)).ToArray());
     containers.Clear();
     this.logs.Clear();
     timeout = null;
 }
Пример #3
0
        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);
        }