-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a HEALTHCHECK to the images #1237
Comments
Some of this is discussed in #920 |
Indeed, see https://github.com/docker-library/faq#healthcheck and the resulting non-triviality of https://github.com/docker-library/healthcheck/blob/master/postgres/docker-healthcheck |
Why not include healthcheck script but not enable it by default to make things a bit easier? |
IMHO included healthcheck should have these features:
|
I was also struggling with a health check until I discovered that My healthcheck:
|
See #920 (comment), especially:
(Your example will report "healthy" before the container is actually ready for external connections because it will happily connect to the unix socket of the initialization instance.) |
Rebuttal of the FAQ below…
As mentioned above, users can customize the instruction as they wish. Checking whether the server is ready to accept a connection seems like a reasonable default.
Yes, this is a small breaking change. But we should also be open to breaking changes; otherwise, we will be stuck with less-than-ideal solutions. Besides, in what use cases would it make sense not to add the
Kubernetes disables Docker’s
The root cause here is that the configured timeout is too small. The solution is to increase the timeout, not to disable the |
When helping people on StackOverflow, I often see people having problems with Docker Compose and applications that try to connect to the database immediately on startup. When using a simple docker compose 'depends_on' directive, compose only waits for the database to be started before starting the application. The application then fails because the database isn't ready to accept connections yet.
The solution is to add a healthcheck to the database container in docker compose and have the application wait for the database to enter a healthy state.
It would be nice if the healthcheck was included in the Postgres image by default. A simple
HEALTHCHECK ["pg_isready"]
should be enough.The text was updated successfully, but these errors were encountered: