0
0
Spring Bootframework~20 mins

Health checks in Docker in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Health Check Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
Understanding Docker HEALTHCHECK command behavior
Consider a Dockerfile with the following HEALTHCHECK instruction:
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?
ADocker will restart the container immediately after the first failed health check.
BThe container health status will remain 'healthy' because the app is running.
CThe container health status will be 'starting' indefinitely.
DThe container health status will be 'unhealthy' after the third failed check.
Attempts:
2 left
💡 Hint
Docker marks a container unhealthy only after consecutive failed health checks.
📝 Syntax
intermediate
2: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?
AHEALTHCHECK CMD curl -f http://localhost:8080/actuator/health || exit 1
BHEALTHCHECK CMD curl http://localhost:8080/actuator/health || exit 1
CHEALTHCHECK CMD curl -s http://localhost:8080/actuator/health
DHEALTHCHECK CMD curl -f http://localhost:8080/actuator/health && exit 1
Attempts:
2 left
💡 Hint
The -f flag makes curl fail on HTTP errors.
state_output
advanced
2:00remaining
Spring Boot actuator health status effect on Docker health
If a Spring Boot application exposes /actuator/health with the following JSON response:
{"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?
Ahealthy, because the HTTP status code is 200 even if status is DOWN
Bunhealthy, because the JSON contains 'DOWN' status
Cstarting, because the health endpoint is not reachable
Dunhealthy, because the HTTP status code is 503 or 500
Attempts:
2 left
💡 Hint
Docker health checks rely on command exit codes, not JSON content.
🔧 Debug
advanced
2:00remaining
Diagnosing failing Docker health check with Spring Boot
A Docker container running a Spring Boot app has this Dockerfile line:
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?
ADocker does not support health checks for Spring Boot apps.
BThe curl command is missing the -f flag to fail on HTTP errors.
CThe Spring Boot actuator endpoint is disabled or not exposed on port 8080.
DThe Dockerfile is missing EXPOSE 8080 instruction.
Attempts:
2 left
💡 Hint
Check if the health endpoint is reachable inside the container.
🧠 Conceptual
expert
3: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?
AParse the JSON response from /actuator/health in a custom script inside Docker HEALTHCHECK.
BConfigure Spring Boot actuator to return HTTP 503 when unhealthy and use curl -f in Docker HEALTHCHECK.
CUse Docker HEALTHCHECK to ping any open port without checking application health.
DDisable Docker HEALTHCHECK and rely on container restart policies only.
Attempts:
2 left
💡 Hint
Think about how Docker interprets health check command success or failure.