Challenge - 5 Problems
Health Check Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Health check status output in Docker Compose
Given this Docker Compose service with a health check, what will be the output of
docker-compose ps after the container starts and the health check passes?Docker
services:
web:
image: nginx
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 10s
timeout: 5s
retries: 3Attempts:
2 left
💡 Hint
Think about what the health check does and how Docker reports container health.
✗ Incorrect
The health check runs curl to check if the web server responds. If it succeeds, Docker marks the container as healthy, so the status shows 'Up (healthy)'.
🧠 Conceptual
intermediate1:30remaining
Purpose of health checks in Docker Compose
What is the main purpose of defining a health check in a Docker Compose service?
Attempts:
2 left
💡 Hint
Think about what health means for a running service.
✗ Incorrect
Health checks let Docker know if the app inside the container is running properly, beyond just the container being up.
❓ Configuration
advanced2:30remaining
Correct health check syntax in Docker Compose
Which of these Docker Compose health check configurations is syntactically correct and will run a command every 30 seconds with a 10-second timeout?
Attempts:
2 left
💡 Hint
The test command must be an array starting with CMD for Compose health checks.
✗ Incorrect
Option A uses the correct array syntax with CMD and valid interval and timeout units. Others have syntax errors or missing CMD.
❓ Troubleshoot
advanced2:00remaining
Diagnosing failing health checks in Compose
You have a health check in Compose that always reports 'unhealthy'. Which command helps you see the detailed health check logs for the container?
Attempts:
2 left
💡 Hint
You want to see the health check results stored in container state.
✗ Incorrect
The docker inspect command with .State.Health shows health check logs and status details.
🔀 Workflow
expert3:00remaining
Using health checks to control service startup order
In Docker Compose, how can you ensure that a service
app starts only after the db service is healthy?Attempts:
2 left
💡 Hint
Compose supports waiting for health status in depends_on since version 3.4.
✗ Incorrect
Using depends_on with condition: service_healthy makes Compose wait for the db service to be healthy before starting app.