Container Health Check
You can setup health checks to see if your program/service is running correctly using an http endpoint.
This will either show Healthy or Unhealthy on the container so you can see if there is an issue that needs fixing such as the database connection going down.

To setup a health check modify your docker-compose.yml with these settings. Change the port and /api/health path to your endpoint.
services:
container:
healthcheck:
test: curl -s --fail-with-body http://localhost:9998/api/health || exit 1
interval: 60s
timeout: 30s
retries: 2
start_period: 15s
This will check your web/api endpoint for a success response being healthy and a 400/500 response being unhealthy.
You can also optionally respond back with json data that can be shown on your container with details on what the issue is.

Last updated