From 5ed2de158ff8a234f0d5d8380bd44a41c616225c Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Thu, 11 Jul 2019 20:18:56 +0300 Subject: [PATCH] healthcheck: reject empty commands An image with "HEALTHCHECK CMD ['']" is valid but as there is no command defined the healthcheck will fail. Reject such a configuration. Fixes #3507 Signed-off-by: Stefan Becker --- libpod/healthcheck.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go index e9bf984e27..8ed2b12e1b 100644 --- a/libpod/healthcheck.go +++ b/libpod/healthcheck.go @@ -123,6 +123,9 @@ func (c *Container) runHealthCheck() (HealthCheckStatus, error) { // command supplied on command line - pass as-is newCommand = hcCommand } + if len(newCommand) < 1 || newCommand[0] == "" { + return HealthCheckNotDefined, errors.Errorf("container %s has no defined healthcheck", c.ID()) + } captureBuffer := bufio.NewWriter(&capture) hcw := hcWriteCloser{ captureBuffer,