Bird
0
0

Which Dockerfile snippet correctly implements this?

hard📝 Application Q8 of 15
Spring Boot - Docker and Deployment

You want to configure a Docker health check for your Spring Boot container that attempts the health endpoint 5 times with 10 seconds interval before marking the container unhealthy. Which Dockerfile snippet correctly implements this?

AHEALTHCHECK --timeout=10s --start-period=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
BHEALTHCHECK --interval=10s --retries=5 CMD curl -f http://localhost:8080/actuator/health || exit 1
CHEALTHCHECK --interval=5s --retries=10 CMD curl -f http://localhost:8080/actuator/health || exit 1
DHEALTHCHECK --start-period=10s --timeout=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
Step-by-Step Solution
Solution:
  1. Step 1: Understand Docker HEALTHCHECK options

    --interval sets time between checks; --retries sets max failures before unhealthy.
  2. Step 2: Match requirements

    5 retries with 10 seconds interval matches --interval=10s --retries=5.
  3. Step 3: Verify command correctness

    Using curl -f with exit 1 is correct.
  4. Final Answer:

    HEALTHCHECK --interval=10s --retries=5 CMD curl -f http://localhost:8080/actuator/health || exit 1 -> Option B
  5. Quick Check:

    Use --interval and --retries to control health check timing [OK]
Quick Trick: Use --interval=10s and --retries=5 for desired health check [OK]
Common Mistakes:
  • Confusing timeout with interval
  • Setting retries or interval to wrong values
  • Omitting retries leading to default behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes