Merge pull request #10107 from jfrazelle/9328-fix-try-start-paused-container

Error should show when trying to start a paused container.
This commit is contained in:
Victor Vieux 2015-01-14 17:02:23 -08:00
Родитель 95c0f07966 02246d2d9f
Коммит 27f69b0777
2 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

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

Просмотреть файл

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