Fix exec form of HEALTHCHECK CMD
We attached the JSON flag to the wrong AST node, causing Docker to treat the exec form ["binary", "arg"] as if the shell form "binary arg" had been used. This failed if "ls" was not present. Added a test to detect this. Fixes #26174 Signed-off-by: Thomas Leonard <thomas.leonard@docker.com>
This commit is contained in:
parent
ad6f5a49d5
commit
e95b6b51da
2 changed files with 16 additions and 1 deletions
|
@ -357,5 +357,5 @@ func parseHealthConfig(rest string, d *Directive) (*Node, map[string]bool, error
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
return &Node{Value: typ, Next: cmd, Attributes: attrs}, nil, err
|
||||
return &Node{Value: typ, Next: cmd}, attrs, err
|
||||
}
|
||||
|
|
|
@ -149,4 +149,19 @@ func (s *DockerSuite) TestHealth(c *check.C) {
|
|||
c.Check(last.ExitCode, checker.Equals, -1)
|
||||
c.Check(last.Output, checker.Equals, "Health check exceeded timeout (1ms)")
|
||||
dockerCmd(c, "rm", "-f", "test")
|
||||
|
||||
// Check JSON-format
|
||||
_, err = buildImage(imageName,
|
||||
`FROM busybox
|
||||
RUN echo OK > /status
|
||||
CMD ["/bin/sleep", "120"]
|
||||
STOPSIGNAL SIGKILL
|
||||
HEALTHCHECK --interval=1s --timeout=30s \
|
||||
CMD ["cat", "/my status"]`,
|
||||
true)
|
||||
c.Check(err, check.IsNil)
|
||||
out, _ = dockerCmd(c, "inspect",
|
||||
"--format={{.Config.Healthcheck.Test}}", imageName)
|
||||
c.Check(out, checker.Equals, "[CMD cat /my status]\n")
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue