mirror of
https://github.com/moby/moby.git
synced 2026-08-08 17:11:38 +00:00
fix a panic when the exec fails to start
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
This commit is contained in:
@@ -595,3 +595,14 @@ func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
|
||||
c.Fatalf("exec into a read-only container failed with exit status %d", status)
|
||||
}
|
||||
}
|
||||
|
||||
// #15750
|
||||
func (s *DockerSuite) TestExecStartFails(c *check.C) {
|
||||
name := "exec-15750"
|
||||
dockerCmd(c, "run", "-d", "--name", name, "busybox", "top")
|
||||
|
||||
_, errmsg, status := dockerCmdWithStdoutStderr(nil, "exec", name, "no-such-cmd")
|
||||
if status == 255 && !strings.Contains(errmsg, "executable file not found") {
|
||||
c.Fatal("exec error message not received. The daemon might had crashed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,7 +602,9 @@ func dockerCmdWithError(args ...string) (string, int, error) {
|
||||
|
||||
func dockerCmdWithStdoutStderr(c *check.C, args ...string) (string, string, int) {
|
||||
stdout, stderr, status, err := runCommandWithStdoutStderr(exec.Command(dockerBinary, args...))
|
||||
c.Assert(err, check.IsNil, check.Commentf("%q failed with errors: %s, %v", strings.Join(args, " "), stderr, err))
|
||||
if c != nil {
|
||||
c.Assert(err, check.IsNil, check.Commentf("%q failed with errors: %s, %v", strings.Join(args, " "), stderr, err))
|
||||
}
|
||||
return stdout, stderr, status
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user