Bird
0
0

Which of the following is the correct way to define a Docker health check that uses curl to verify a Spring Boot app's /actuator/health endpoint?

easy📝 Syntax Q3 of 15
Spring Boot - Docker and Deployment

Which of the following is the correct way to define a Docker health check that uses curl to verify a Spring Boot app's /actuator/health endpoint?

AHEALTHCHECK EXEC curl http://localhost:8080/actuator/health
BHEALTHCHECK RUN curl http://localhost:8080/actuator/health
CHEALTHCHECK CMD curl -f http://localhost:8080/actuator/health || exit 1
DHEALTHCHECK CMD-TEST curl http://localhost:8080/actuator/health
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct HEALTHCHECK syntax

    The correct Dockerfile syntax uses HEALTHCHECK CMD followed by the command.
  2. Step 2: Use curl with -f flag

    The -f flag makes curl fail on HTTP errors, which is needed for health check.
  3. Final Answer:

    HEALTHCHECK CMD curl -f http://localhost:8080/actuator/health || exit 1 -> Option C
  4. Quick Check:

    Use HEALTHCHECK CMD with curl -f for proper health checks [OK]
Quick Trick: Use HEALTHCHECK CMD with curl -f and exit 1 [OK]
Common Mistakes:
  • Using RUN instead of CMD in HEALTHCHECK
  • Omitting the -f flag in curl
  • Using invalid HEALTHCHECK keywords like EXEC or CMD-TEST

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes