Complete the Docker healthcheck command to check if the container is healthy.
HEALTHCHECK CMD curl -f http://localhost[1] || exit 1
The healthcheck uses port 80 by default to check the /health endpoint.
Complete the Docker Compose healthcheck interval setting to run every 30 seconds.
healthcheck: test: ["CMD", "curl", "-f", "http://localhost/health"] interval: [1]
The interval setting defines how often the healthcheck runs. 30s means every 30 seconds.
Fix the error in the healthcheck test command to correctly check container health.
healthcheck:
test: [1]The test command must be an array starting with "CMD" followed by the command and arguments.
Fill both blanks to set the healthcheck retries and timeout values.
healthcheck: retries: [1] timeout: [2]
Retries is the number of attempts before marking unhealthy. Timeout is how long to wait for each check.
Fill all three blanks to create a healthcheck that runs every 20 seconds, retries 4 times, and has a timeout of 15 seconds.
healthcheck: interval: [1] retries: [2] timeout: [3]
The interval is how often to run the check, retries is how many times to retry, and timeout is how long to wait for each check.