Skip to content

Instantly share code, notes, and snippets.

@beci
Last active November 7, 2022 22:26
Show Gist options
  • Save beci/e968d16363e71c77a1aa0495cdde5161 to your computer and use it in GitHub Desktop.
Save beci/e968d16363e71c77a1aa0495cdde5161 to your computer and use it in GitHub Desktop.
A sample (from featmap) docker service definition with healthcheck
# link https://gist.githubusercontent.com/beci/e968d16363e71c77a1aa0495cdde5161/raw/c6a39779c8a951283f38af0d390484f6bb2ee837/docker-compose-postgres-with-healt-check.txt
#
postgres:
image: postgres:11-alpine
restart: always
volumes:
- ${PWD}/data:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${FEATMAP_DB}
POSTGRES_USER: ${FEATMAP_DB_USER}
POSTGRES_PASSWORD: ${FEATMAP_DB_PASSWORD}
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${FEATMAP_DB_USER}" ]
interval: 10s
timeout: 5s
retries: 5
@beci
Copy link
Author

beci commented Sep 18, 2022

And on the depending service:

        depends_on:
            postgres:
                condition: service_healthy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment