Bird
0
0

You added this line to your Dockerfile:

medium📝 Debug Q6 of 15
Spring Boot - Docker and Deployment

You added this line to your Dockerfile:

HEALTHCHECK CMD curl -f http://localhost:8080/actuator/health || exit 1

but the health check never executes after container start. What is a likely reason?

AThe container image does not include the <code>curl</code> binary.
BThe <code>HEALTHCHECK</code> instruction must be placed before <code>CMD</code> in Dockerfile.
CThe health check URL is incorrect and returns 404.
DDocker requires health checks to be disabled explicitly.
Step-by-Step Solution
Solution:
  1. Step 1: Check if curl is available

    If curl is missing, the health check command cannot run, so it never executes properly.
  2. Step 2: Other options analysis

    Placement of HEALTHCHECK relative to CMD is flexible; incorrect URL would cause failures but still run; Docker does not require disabling health checks.
  3. Final Answer:

    The container image does not include the curl binary. -> Option A
  4. Quick Check:

    Missing curl binary prevents health check execution [OK]
Quick Trick: Missing curl in image causes health check to fail silently [OK]
Common Mistakes:
  • Assuming HEALTHCHECK must be before CMD
  • Thinking Docker disables health checks by default
  • Ignoring missing dependencies in container

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes