DCA · Question #98
The following Docker Compose file is deployed as a stack: Is this statement correct about this health check definition? Solution: Health checks test for app health ten seconds apart. If the test fails
The correct answer is B. No. This statement incorrectly describes the behavior of Docker Compose health checks regarding container restarts.
Question
The following Docker Compose file is deployed as a stack:
Is this statement correct about this health check definition? Solution: Health checks test for app health ten seconds apart. If the test fails, the container will be restarted three times before it gets rescheduled.
Options
- AYes
- BNo
How the community answered
(14 responses)- A29% (4)
- B71% (10)
Why each option
This statement incorrectly describes the behavior of Docker Compose health checks regarding container restarts.
The `retries` parameter dictates how many failures lead to an unhealthy state, not how many times a container is automatically restarted by the health check mechanism.
Docker Compose health checks with `retries: 3` define how many consecutive failures lead to an 'unhealthy' status, but they do not inherently trigger container restarts. Restarting a container upon health check failure requires a separate `restart_policy` configuration for the service.
Concept tested: Docker Compose health check vs. restart policy
Source: https://docs.docker.com/compose/compose-file/05-services/#healthcheck
Topics
Community Discussion
No community discussion yet for this question.