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") +}