Complete the code to define a health check command in Docker Compose.
healthcheck: test: ["CMD", [1]]
The health check command must return 0 on success. Using curl -f http://localhost/ || exit 1 ensures failure if the service is down.
Complete the code to set the health check interval to 30 seconds.
healthcheck:
interval: [1]The interval defines how often the health check runs. Setting it to 30s means every 30 seconds.
Fix the error in the health check restart policy syntax.
restart: [1]The correct restart policy to restart containers unless stopped manually is unless-stopped.
Fill both blanks to set retries to 5 and timeout to 10 seconds in health check.
healthcheck: retries: [1] timeout: [2]
Retries define how many times to retry before marking unhealthy. Timeout is how long to wait for each check. Here, 5 retries and 10 seconds timeout are set.
Fill all three blanks to create a health check with command 'curl -f http://localhost/', interval 20 seconds, and start period 5 seconds.
healthcheck: test: ["CMD", [1]] interval: [2] start_period: [3]
The test command must fail if the service is unhealthy. Interval is how often to run the check. Start period is the initial delay before checks start.