DCA · Question #43
The following health check exists in a Dockerfile: Which of the following describes its purpose?
The correct answer is A. Defines the action taken when container health fails, which in this case will kill the container with. The Dockerfile HEALTHCHECK instruction defines a mechanism for Docker to monitor a container's health, enabling orchestration systems to take remedial actions when the health check fails.
Question
The following health check exists in a Dockerfile:
Which of the following describes its purpose?
Options
- ADefines the action taken when container health fails, which in this case will kill the container with
- BDefines the health check endpoint on the localhost interface for external monitoring tools to
- CDefines the health check endpoint on the local host interface for containers to monitor the health of
- DDefines the health check for the containerized application so that the application health can be
How the community answered
(33 responses)- A94% (31)
- C3% (1)
- D3% (1)
Why each option
The Dockerfile HEALTHCHECK instruction defines a mechanism for Docker to monitor a container's health, enabling orchestration systems to take remedial actions when the health check fails.
The `HEALTHCHECK` instruction in a Dockerfile specifies a command to determine if the application inside the container is functioning correctly. When this health check consistently fails, Docker updates the container's health status to 'unhealthy', which then enables orchestration platforms (like Docker Swarm or Kubernetes) to automatically take remedial actions such as stopping (killing) the unhealthy container and potentially replacing it.
The `HEALTHCHECK` command runs *inside* the container to check its internal state; it does not expose an external endpoint on the host for monitoring tools.
Similar to B, the instruction checks internal health within the container, not providing an endpoint on the host for other containers.
While it defines a health check, this statement is too general and doesn't capture the crucial aspect of what happens or is enabled when the health check fails, which is implied by the correct answer.
Concept tested: Dockerfile HEALTHCHECK instruction purpose
Source: https://docs.docker.com/engine/reference/builder/#healthcheck
Topics
Community Discussion
No community discussion yet for this question.