-
Notifications
You must be signed in to change notification settings - Fork 315
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
docker-compose health check should be aware of restart during install of postgis extension #420
Comments
Doesn't the health check occur after the last restart of the DB? |
That health check is done via docker engine. It doesnt know if it is up or not. |
Revisiting this again, how do we check for the health check if
Assuming a user hasn't installed the postgis extension? |
Just chiming here, I've just faced the same issue where the postgres container with postgis would look healthy from I ended up using @devrimbaris solution for the health check, I had to add Ideally, Here's my full service definition for reference services:
postgres:
container_name: postgres
image: postgis/postgis:16-3.4-alpine
platform: linux/amd64
restart: unless-stopped
environment:
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
PGUSER: some_user
POSTGRES_DB: some_db
ports:
- "5433:5432"
healthcheck:
test:
[
"CMD-SHELL",
'psql -U some_user -d some_db -c "SELECT ST_Buffer( ST_SetSRID(''POINT(0 0)''::GEOMETRY, 4326), 1) AS geom ;"',
]
interval: 2s
timeout: 1s
retries: 5 |
@Cellule The main question hasn't been answered. What if a user doesn't install PostGIS i.e
|
I'm not sure I understand, you mean what should the healthcheck be if postgis extension is not installed? |
Yes, Even though this is mainly geared toward Postgis, there could be rare situations where the users could run without the Postgis extension. In any case, I am not against this but maybe raise a PR and also add some notes in the README indicating that this is only valid if the Postgis extension is installed |
Feature description
Hi,
Currently the pg_isready check seems to return true when initial container starts. However after postgis extensions are installed the database is shut down. The second service may get the healthy trigger and try to connect to a shutdown postgresql.
A check like following which actually checks postgis extension installation may help overcome this issue:
test: [ "CMD-SHELL","psql -U docker -d fsdb -c \"SELECT ST_Buffer( ST_SetSRID('POINT(0 0)'::GEOMETRY, 4326), 1) AS geom ;\""]
Additional context
No response
The text was updated successfully, but these errors were encountered: