1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #9583 from brahmaroutu/remove_container_9569

Error should be 409 as the container is different state to remove
This commit is contained in:
Alexander Morozov 2014-12-23 10:09:58 -08:00
commit 1e2d0d17d9
2 changed files with 19 additions and 1 deletions

View file

@ -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) return job.Errorf("Could not kill running container, cannot remove - %v", err)
} }
} else { } 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 { if err := daemon.Destroy(container); err != nil {

View file

@ -57,6 +57,24 @@ func TestRmRunningContainer(t *testing.T) {
logDone("rm - running container") 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) { func TestRmForceRemoveRunningContainer(t *testing.T) {
createRunningContainer(t, "foo") createRunningContainer(t, "foo")