Merge pull request #47 from seemethere/cherry_pick_33249

Add container environment variables correctly to the health check
This commit is contained in:
Andrew Hsu
2017-06-09 15:32:27 -07:00
committed by GitHub
2 changed files with 38 additions and 11 deletions

View File

@ -139,3 +139,26 @@ func (s *DockerSuite) TestHealth(c *check.C) {
c.Check(out, checker.Equals, "[CMD cat /my status]\n")
}
// Github #33021
func (s *DockerSuite) TestUnsetEnvVarHealthCheck(c *check.C) {
testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
imageName := "testhealth"
buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox
HEALTHCHECK --interval=1s --timeout=5s --retries=5 CMD /bin/sh -c "sleep 1"
ENTRYPOINT /bin/sh -c "sleep 600"`))
name := "env_test_health"
// No health status before starting
dockerCmd(c, "run", "-d", "--name", name, "-e", "FOO", imageName)
defer func() {
dockerCmd(c, "rm", "-f", name)
dockerCmd(c, "rmi", imageName)
}()
// Start
dockerCmd(c, "start", name)
waitForHealthStatus(c, name, "starting", "healthy")
}