0
0
Dockerdevops~20 mins

Container health checks in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container Health Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of the health check status command?
You have a Docker container running with a health check configured. You run the command docker inspect --format='{{.State.Health.Status}}' mycontainer. What output do you expect if the container is healthy?
Astarting
Bunhealthy
Chealthy
Dexited
Attempts:
2 left
💡 Hint
Think about the possible health states Docker reports.
🧠 Conceptual
intermediate
1:30remaining
Which Dockerfile instruction defines a health check?
In a Dockerfile, which instruction is used to define a container health check?
ASTATUSCHECK
BHEALTHCHECK
CRUNHEALTH
DCHECKHEALTH
Attempts:
2 left
💡 Hint
It is a single word instruction starting with HEALTH.
Configuration
advanced
2:00remaining
Identify the correct health check configuration in Dockerfile
Which of the following Dockerfile snippets correctly configures a health check that runs curl -f http://localhost/ || exit 1 every 30 seconds with a timeout of 10 seconds?
AHEALTHCHECK CMD curl -f http://localhost/ || exit 1 --interval=30s --timeout=10s
BHEALTHCHECK --timeout=10s --interval=30s RUN curl -f http://localhost/ || exit 1
CHEALTHCHECK CMD --interval=30s --timeout=10s curl -f http://localhost/ || exit 1
DHEALTHCHECK --interval=30s --timeout=10s CMD curl -f http://localhost/ || exit 1
Attempts:
2 left
💡 Hint
Options flags come immediately after HEALTHCHECK, before CMD.
Troubleshoot
advanced
2:00remaining
Why does the health check always show 'starting' status?
You configured a health check in your Docker container, but docker inspect always shows the status as starting. What is the most likely cause?
AThe health check command never exits or takes longer than the timeout
BThe container is stopped and not running
CThe Docker daemon is not running
DThe health check command is missing from the Dockerfile
Attempts:
2 left
💡 Hint
Think about what 'starting' means in health check lifecycle.
Best Practice
expert
2:30remaining
What is the best practice for health check command exit codes?
For Docker container health checks, which exit code convention should the health check command follow to indicate a healthy or unhealthy state?
AExit code 0 means healthy; any non-zero exit code means unhealthy
BExit code 1 means healthy; exit code 0 means unhealthy
CExit code 2 means healthy; exit code 1 means unhealthy
DExit code 0 means unhealthy; exit code 1 means healthy
Attempts:
2 left
💡 Hint
Think about standard Unix command exit codes.