0
0
Spring Bootframework~5 mins

Health checks in Docker in Spring Boot - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of a health check in Docker?
A health check in Docker helps to automatically verify if a container is running correctly and is ready to serve requests. It ensures the container is healthy and can restart or alert if it is not.
Click to reveal answer
beginner
How do you define a health check in a Dockerfile?
You use the HEALTHCHECK instruction in a Dockerfile to specify a command that tests the container's health. For example: <br>HEALTHCHECK --interval=30s CMD curl -f http://localhost:8080/actuator/health || exit 1
Click to reveal answer
beginner
What Spring Boot feature is commonly used to support Docker health checks?
Spring Boot Actuator provides an endpoint /actuator/health that returns the health status of the application. Docker health checks can call this endpoint to verify if the app is healthy.
Click to reveal answer
intermediate
What does Docker do if a health check fails repeatedly?
If a health check fails repeatedly, Docker marks the container as unhealthy. Depending on the orchestration setup, it can restart the container or notify the user to fix the issue.
Click to reveal answer
intermediate
Why is it important to set a proper interval and timeout for Docker health checks?
Setting a proper interval and timeout balances between timely detection of issues and avoiding unnecessary load on the container. Too frequent checks can cause overhead; too slow checks delay problem detection.
Click to reveal answer
Which Dockerfile instruction is used to add a health check?
ACHECKHEALTH
BHEALTHCHECK
CRUNHEALTH
DTESTHEALTH
What Spring Boot endpoint is typically used for Docker health checks?
A/actuator/health
B/healthcheck
C/status
D/check
What happens if a Docker container's health check fails multiple times?
ADocker ignores the failure
BDocker deletes the container
CDocker marks the container unhealthy
DDocker upgrades the container
Which command is a good example of a Docker health check for a Spring Boot app?
Acurl -f http://localhost:8080/actuator/health || exit 1
Bping localhost
Cls /app
Decho 'healthy'
Why should health checks not run too frequently?
ATo speed up container startup
BTo save disk space
CTo reduce network traffic
DTo avoid extra load on the container
Explain how to add a health check to a Spring Boot application running in Docker.
Think about how Docker verifies container health and how Spring Boot exposes health info.
You got /4 concepts.
    Describe what happens when a Docker container's health check fails repeatedly and why this is useful.
    Consider the benefits of automatic health monitoring.
    You got /4 concepts.