Challenge - 5 Problems
Docker Health Check Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
Understanding Docker HEALTHCHECK command behavior
Consider a Dockerfile with the following HEALTHCHECK instruction:
What will Docker report as the container health status if the Spring Boot app's /actuator/health endpoint returns HTTP 503 for 3 consecutive checks?
HEALTHCHECK --interval=10s --timeout=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
What will Docker report as the container health status if the Spring Boot app's /actuator/health endpoint returns HTTP 503 for 3 consecutive checks?
Attempts:
2 left
💡 Hint
Docker marks a container unhealthy only after consecutive failed health checks.
✗ Incorrect
Docker runs the HEALTHCHECK command periodically. If the command fails consecutively (default 3 times), Docker marks the container as 'unhealthy'. HTTP 503 causes curl -f to fail, so after 3 failures, status is 'unhealthy'.
📝 Syntax
intermediate2:00remaining
Correct syntax for Docker HEALTHCHECK with Spring Boot
Which of the following Dockerfile HEALTHCHECK instructions correctly checks the Spring Boot actuator health endpoint at http://localhost:8080/actuator/health?
Attempts:
2 left
💡 Hint
The -f flag makes curl fail on HTTP errors.
✗ Incorrect
Option A uses 'curl -f' which fails on HTTP errors, triggering the health check failure correctly. Option A lacks -f so it won't fail on HTTP errors. Option A is silent but does not fail on errors. Option A wrongly uses && exit 1 which always exits with failure.
❓ state_output
advanced2:00remaining
Spring Boot actuator health status effect on Docker health
If a Spring Boot application exposes /actuator/health with the following JSON response:
and the Docker HEALTHCHECK runs:
What will be the Docker container health status?
{"status":"DOWN","components":{"db":{"status":"DOWN"}}}and the Docker HEALTHCHECK runs:
curl -f http://localhost:8080/actuator/health || exit 1
What will be the Docker container health status?
Attempts:
2 left
💡 Hint
Docker health checks rely on command exit codes, not JSON content.
✗ Incorrect
The curl command fails only if HTTP status is an error (4xx or 5xx). Spring Boot actuator returns HTTP 200 even if status is DOWN. So curl -f succeeds, Docker marks container healthy.
🔧 Debug
advanced2:00remaining
Diagnosing failing Docker health check with Spring Boot
A Docker container running a Spring Boot app has this Dockerfile line:
But Docker always shows the container as unhealthy. Which of the following is the most likely cause?
HEALTHCHECK CMD curl -f http://localhost:8080/actuator/health || exit 1
But Docker always shows the container as unhealthy. Which of the following is the most likely cause?
Attempts:
2 left
💡 Hint
Check if the health endpoint is reachable inside the container.
✗ Incorrect
If the actuator endpoint is disabled or the app listens on a different port, curl fails, causing health check failure. Missing -f flag would not cause failure. Docker supports health checks. EXPOSE is optional for health checks.
🧠 Conceptual
expert3:00remaining
Best practice for integrating Spring Boot health with Docker health checks
Which approach best ensures Docker health status accurately reflects Spring Boot application health?
Attempts:
2 left
💡 Hint
Think about how Docker interprets health check command success or failure.
✗ Incorrect
Configuring Spring Boot to return HTTP 503 when unhealthy allows curl -f to fail, signaling Docker correctly. Parsing JSON in Docker HEALTHCHECK is complex and error-prone. Pinging ports does not reflect app health. Disabling health checks loses health visibility.