issue with healthcheck on postgres/alpine 18.4 #1414
Replies: 2 comments 2 replies
-
|
See #1237, https://github.com/docker-library/faq#healthcheck, and https://github.com/docker-library/healthcheck/blob/master/postgres/docker-healthcheck |
Beta Was this translation helpful? Give feedback.
-
|
This is often caused by an environment variable expansion issue in the healthcheck script or compose configuration, combined with how PostgreSQL handles client connection attempts. Why this happensThe log: usually indicates that In the official How to fix it in your Compose fileMake sure your healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 10s
timeout: 5s
retries: 5
Alternatively, hardcode the default postgres user and database if you aren't changing them: healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]Checking if it's Podman-specificIf you are using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
im runnning postgres alpine latest version in podman with podman-compose
here is my compose file:
.env file
the issue:
healthcheck returns error and condition healthy never arrives. status of the container hangs on 'starting' if i use healtcheck in compose.
however if i manually run pg_isready on the container from host, there seems to be nothing that would indicate that something is 'not healthy'.
in logs, i see that healthcheck command is probably getting this FATAL value from the postgres container:
however when i run pg_isready from the host i receive this on stdout:
also here it looks like the db exists, contrary to logs:
to me at least, it indicates that there is no error and the database exists. maybe i am missing something
Beta Was this translation helpful? Give feedback.
All reactions