From 021abfe68567a1bd58ee5f85ae2f029cf051b228 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Fri, 17 Nov 2023 15:19:08 -0500 Subject: [PATCH] Postgres: Add healthcheck examples --- postgres/content.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/postgres/content.md b/postgres/content.md index 0f98b18ed2a0f..fe6660e69a6bd 100644 --- a/postgres/content.md +++ b/postgres/content.md @@ -40,6 +40,29 @@ postgres=# SELECT 1; Run `docker stack deploy -c stack.yml %%REPO%%` (or `docker-compose -f stack.yml up`), wait for it to initialize completely, and visit `http://swarm-ip:8080`, `http://localhost:8080`, or `http://host-ip:8080` (as appropriate). +## Healtcheck + +To add a health check to the image use the following command: + +```console +docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword \ + --health-cmd='pg_isready' --health-interval=30s -d %%IMAGE%% +``` + +or using docker-compose + +```yaml +services: + postgres: + image: postgres + restart: always + environment: + POSTGRES_PASSWORD: example + healthcheck: + test: pg_isready + interval: 30s +``` + # How to extend this image There are many ways to extend the `%%REPO%%` image. Without trying to support every possible use case, here are just a few that we have found useful.