From 6599aa3368f369e6b8632cc2c12f214b0450a5a6 Mon Sep 17 00:00:00 2001 From: Srini Brahmaroutu Date: Tue, 9 Dec 2014 20:04:33 +0000 Subject: [PATCH] Error should be 409 as the container is different state to remove Closes #9569 Signed-off-by: Srini Brahmaroutu --- daemon/delete.go | 2 +- integration-cli/docker_cli_rm_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/daemon/delete.go b/daemon/delete.go index 55678f90a1..990e4b448a 100644 --- a/daemon/delete.go +++ b/daemon/delete.go @@ -55,7 +55,7 @@ func (daemon *Daemon) ContainerRm(job *engine.Job) engine.Status { return job.Errorf("Could not kill running container, cannot remove - %v", err) } } else { - return job.Errorf("You cannot remove a running container. Stop the container before attempting removal or use -f") + return job.Errorf("Conflict, You cannot remove a running container. Stop the container before attempting removal or use -f") } } if err := daemon.Destroy(container); err != nil { diff --git a/integration-cli/docker_cli_rm_test.go b/integration-cli/docker_cli_rm_test.go index 6681840ecd..c3069a3eed 100644 --- a/integration-cli/docker_cli_rm_test.go +++ b/integration-cli/docker_cli_rm_test.go @@ -57,6 +57,24 @@ func TestRmRunningContainer(t *testing.T) { logDone("rm - running container") } +func TestRmRunningContainerCheckError409(t *testing.T) { + createRunningContainer(t, "foo") + + endpoint := "/containers/foo" + _, err := sockRequest("DELETE", endpoint, nil) + + if err == nil { + t.Fatalf("Expected error, can't rm a running container") + } + if !strings.Contains(err.Error(), "409 Conflict") { + t.Fatalf("Expected error to contain '409 Conflict' but found", err) + } + + deleteAllContainers() + + logDone("rm - running container") +} + func TestRmForceRemoveRunningContainer(t *testing.T) { createRunningContainer(t, "foo")