The health check is a feature of the container runtime that can be used to check on the health of an application running within the container and restart the container if it is not healthy. For example, if a web server is running inside of a container, the curl command could be used to ensure the web server is running and healthy. This is what the configuration would look like:
In this example, the Test field is set to the command that will be executed inside of the container. The specified command is application-specific:
curl -f https://localhost || exit 1
Any exit value from the test command that is not zero tells the container runtime that the test was not successful. An exit value of zero is considered a successful test.
The Interval specifies the duration between test executions. Retries specify the number of test failures that constitutes an unhealthy container. The Timeout is the time duration the test must execute within before it is considered a failed test. Finally, the Condition specifies under what condition the container should be restarted. For further information on health checks, see the Docker Compose documentation.