Bird
0
0

Which HEALTHCHECK instruction correctly implements this?

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

You want Docker to check your Spring Boot app health every 30 seconds, retry 3 times before marking unhealthy, and start checking only after 10 seconds of container start. Which HEALTHCHECK instruction correctly implements this?

AHEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD curl --fail http://localhost:8080/actuator/health || exit 1
BHEALTHCHECK --interval=10s --timeout=30s --start-period=3s --retries=5 CMD curl --fail http://localhost:8080/actuator/health || exit 1
CHEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl http://localhost:8080/actuator/health || exit 1
DHEALTHCHECK CMD curl --fail http://localhost:8080/actuator/health || exit 1
Step-by-Step Solution
Solution:
  1. Step 1: Match timing parameters to requirements

    Interval 30s means check every 30 seconds, start-period 10s delays first check, retries 3 means try 3 times before unhealthy.
  2. Step 2: Verify curl command correctness

    curl uses --fail to detect HTTP errors, with exit 1 to signal failure to Docker.
  3. Final Answer:

    HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD curl --fail http://localhost:8080/actuator/health || exit 1 -> Option A
  4. Quick Check:

    Correct timing + curl --fail = HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD curl --fail http://localhost:8080/actuator/health || exit 1 [OK]
Quick Trick: Set interval, retries, start-period explicitly with curl --fail [OK]
Common Mistakes:
  • Mixing up interval and timeout values
  • Omitting --fail in curl command
  • Not setting start-period to delay checks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes