зеркало из https://github.com/microsoft/docker.git
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:
Коммит
27f69b0777
|
@ -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")
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче