diff --git a/src/LclDckr/DockerClient.cs b/src/LclDckr/DockerClient.cs index 6b0b7eb..5fd664c 100644 --- a/src/LclDckr/DockerClient.cs +++ b/src/LclDckr/DockerClient.cs @@ -187,9 +187,10 @@ public string StopContainer(string name) /// /// /// - public string RemoveContainer(string name) + public string RemoveContainer(string name, bool force = false) { - var args = $"rm {name}"; + string forceArg = force ? "-f " : ""; + var args = $"rm {forceArg}{name}"; using (var process = GetDockerProcess(args)) { process.Start(); diff --git a/src/LclDckr/project.json b/src/LclDckr/project.json index f2776ee..85aef6d 100644 --- a/src/LclDckr/project.json +++ b/src/LclDckr/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.5-*", + "version": "1.0.6-*", "description": "A dotnet wrapper around the docker cli.", "authors": ["Syncromatics"], "packOptions": { diff --git a/test/LclDckr.IntegrationTests/DockerClientTests.cs b/test/LclDckr.IntegrationTests/DockerClientTests.cs index 5a5dd3f..83f71cf 100644 --- a/test/LclDckr.IntegrationTests/DockerClientTests.cs +++ b/test/LclDckr.IntegrationTests/DockerClientTests.cs @@ -128,5 +128,20 @@ public void Inspects() client.StopAndRemoveContainer(containerName); } } + + [Fact] + 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); + } } } diff --git a/test/LclDckr.IntegrationTests/project.json b/test/LclDckr.IntegrationTests/project.json index 747194f..9b454f3 100644 --- a/test/LclDckr.IntegrationTests/project.json +++ b/test/LclDckr.IntegrationTests/project.json @@ -1,9 +1,9 @@ { - "version": "1.0.5-*", + "version": "1.0.6-*", "testRunner": "xunit", "dependencies": { "xunit": "2.2.0", - "LclDckr": "1.0.5-*", + "LclDckr": "1.0.6-*", "dotnet-test-xunit": "2.2.0-preview2-build1029" }, "buildOptions": {