mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Error should show when trying to start a paused container.
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
This commit is contained in:
parent
f67c6d313b
commit
02246d2d9f
2 changed files with 26 additions and 0 deletions
|
@ -22,6 +22,10 @@ func (daemon *Daemon) ContainerStart(job *engine.Job) engine.Status {
|
||||||
return job.Errorf("No such container: %s", name)
|
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() {
|
if container.IsRunning() {
|
||||||
return job.Errorf("Container already started")
|
return job.Errorf("Container already started")
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,3 +165,25 @@ func TestStartVolumesFromFailsCleanly(t *testing.T) {
|
||||||
|
|
||||||
logDone("start - missing containers in --volumes-from did not affect subsequent runs")
|
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")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue