Healthchecks and Restart Policies in Docker Compose
A healthcheck is a command Docker runs periodically inside the container to decide whether the service is healthy; its state moves from starting to healthy or unhealthy. Combined with a restart policy (no, always, on-failure or unless-stopped) and with depends_on and the service_healthy condition, it stops an application from starting before its database.