Skip to content

Commit

Permalink
Remove command force flag (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethito authored Mar 8, 2017
1 parent 0dff349 commit 6462eaa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/LclDckr/DockerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ public string StopContainer(string name)
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
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();
Expand Down
2 changes: 1 addition & 1 deletion src/LclDckr/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.5-*",
"version": "1.0.6-*",
"description": "A dotnet wrapper around the docker cli.",
"authors": ["Syncromatics"],
"packOptions": {
Expand Down
15 changes: 15 additions & 0 deletions test/LclDckr.IntegrationTests/DockerClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
4 changes: 2 additions & 2 deletions test/LclDckr.IntegrationTests/project.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 6462eaa

Please sign in to comment.