Skip to content

Commit 968fbdb

Browse files
Postgres: Add healthcheck examples
1 parent b96642d commit 968fbdb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

postgres/content.md

+23
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,29 @@ postgres=# SELECT 1;
4040

4141
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).
4242

43+
## Healtcheck
44+
45+
To add a health check to the image use the following command:
46+
47+
```console
48+
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword \
49+
--health-cmd='pg_isready' --health-interval=5s -d %%IMAGE%%
50+
```
51+
52+
or using docker-compose
53+
54+
```yaml
55+
services:
56+
postgres:
57+
image: postgres
58+
restart: always
59+
environment:
60+
POSTGRES_PASSWORD: example
61+
healthcheck:
62+
test: pg_isready
63+
interval: 5s
64+
```
65+
4366
# How to extend this image
4467
4568
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.

0 commit comments

Comments
 (0)