0
0
Dockerdevops~5 mins

Health checks in Compose in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a health check in Docker Compose?
A health check is a way to test if a container is working correctly by running a command inside it regularly. It helps Docker know if the app inside the container is healthy or not.
Click to reveal answer
beginner
Which key is used to define a health check in a Docker Compose service?
The key healthcheck is used under a service in the docker-compose.yml file to define commands and settings for health checks.
Click to reveal answer
intermediate
What does the test option inside a health check specify?
The test option defines the command Docker runs inside the container to check if it is healthy. For example, test: ["CMD", "curl", "-f", "http://localhost"].
Click to reveal answer
intermediate
What happens if a health check fails multiple times in Docker Compose?
If the health check command fails repeatedly, Docker marks the container as unhealthy. This can be used to trigger restarts or alerts.
Click to reveal answer
intermediate
Name two timing options you can set for a health check in Docker Compose.
You can set interval (how often to run the check) and timeout (how long to wait for the check to finish). Others include retries and start_period.
Click to reveal answer
Which key defines a health check in a Docker Compose service?
Atesthealth
Bcheckhealth
Chealth
Dhealthcheck
What does the test option inside a health check do?
ARuns a command inside the container to check health
BSets the health check interval
CDefines the container restart policy
DSpecifies the container image
If a health check fails repeatedly, Docker marks the container as:
Aunhealthy
Bstopped
Cpaused
Drunning
Which of these is NOT a valid health check timing option?
Aretries
Btimeout
Crestart
Dinterval
How often does Docker run the health check command by default if not specified?
A10 seconds
B30 seconds
C1 minute
D5 seconds
Explain how to add a health check to a service in a Docker Compose file.
Think about the keys under the service in docker-compose.yml
You got /3 concepts.
    Describe what happens when a container's health check fails multiple times.
    Focus on Docker's reaction to health check results
    You got /3 concepts.