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?
✗ Incorrect
The correct key to define health checks in Docker Compose is
healthcheck.What does the
test option inside a health check do?✗ Incorrect
The
test option runs a command inside the container to verify if it is healthy.If a health check fails repeatedly, Docker marks the container as:
✗ Incorrect
Repeated health check failures cause Docker to mark the container as unhealthy.
Which of these is NOT a valid health check timing option?
✗ Incorrect
restart is not a health check timing option; it is a separate container policy.How often does Docker run the health check command by default if not specified?
✗ Incorrect
By default, Docker runs health checks every 30 seconds if
interval is not set.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.