Ensure healthcheck instructions have been added to container images

Error: Healthcheck instructions have not been added to container images

Bridgecrew Policy ID: BC_DKR_2
Checkov Check ID: CKV_DOCKER_2
Severity: LOW

Healthcheck instructions have not been added to container images

Description

We recommend that you add the HEALTHCHECK instruction to your Docker container images to ensure that health checks are executed against running containers.

An important security control is that of availability. Adding the HEALTHCHECK instruction to your container image ensures that the Docker engine periodically checks the running container instances against that instruction to ensure that containers are still operational.

Based on the results of the health check, the Docker engine could terminate containers which are not responding correctly, and instantiate new ones.

Fix - Buildtime

Docker

FROM base

LABEL foo="bar baz
USER  me
HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1