From 02246d2d9f9fe8eb040d1eb1ac4b7a84c3f3f059 Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Wed, 14 Jan 2015 16:44:53 -0800 Subject: [PATCH] Error should show when trying to start a paused container. Docker-DCO-1.1-Signed-off-by: Jessica Frazelle (github: jfrazelle) --- daemon/start.go | 4 ++++ integration-cli/docker_cli_start_test.go | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/daemon/start.go b/daemon/start.go index 286ee58a34..363461080f 100644 --- a/daemon/start.go +++ b/daemon/start.go @@ -22,6 +22,10 @@ func (daemon *Daemon) ContainerStart(job *engine.Job) engine.Status { return job.Errorf("No such container: %s", name) } + if container.IsPaused() { + return job.Errorf("Cannot start a paused container, try unpause instead.") + } + if container.IsRunning() { return job.Errorf("Container already started") } diff --git a/integration-cli/docker_cli_start_test.go b/integration-cli/docker_cli_start_test.go index 05a262ba51..3b0617f09e 100644 --- a/integration-cli/docker_cli_start_test.go +++ b/integration-cli/docker_cli_start_test.go @@ -165,3 +165,25 @@ func TestStartVolumesFromFailsCleanly(t *testing.T) { logDone("start - missing containers in --volumes-from did not affect subsequent runs") } + +func TestStartPausedContainer(t *testing.T) { + defer deleteAllContainers() + defer unpauseAllContainers() + + runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "testing", "busybox", "top") + if out, _, err := runCommandWithOutput(runCmd); err != nil { + t.Fatal(out, err) + } + + runCmd = exec.Command(dockerBinary, "pause", "testing") + if out, _, err := runCommandWithOutput(runCmd); err != nil { + t.Fatal(out, err) + } + + runCmd = exec.Command(dockerBinary, "start", "testing") + if out, _, err := runCommandWithOutput(runCmd); err == nil || !strings.Contains(out, "Cannot start a paused container, try unpause instead.") { + t.Fatalf("an error should have been shown that you cannot start paused container: %s\n%v", out, err) + } + + logDone("start - error should show if trying to start paused container") +}