Skip to content

Instantly share code, notes, and snippets.

@grizmio
Created April 13, 2020 16:59
Show Gist options
  • Save grizmio/ed689558a1fa8fd879d8e70c69da4c2f to your computer and use it in GitHub Desktop.
Save grizmio/ed689558a1fa8fd879d8e70c69da4c2f to your computer and use it in GitHub Desktop.
Example to wait for postgres container before start another container using docker-compose.yml
# Credits to: https://github.com/peter-evans
# Extracted from: https://github.com/peter-evans/docker-compose-healthcheck/blob/master/docker-compose.yml
# TL;DR;
version: "2.2"
services:
foo:
image: an_image:tag
networks:
- mean
depends_on:
postgres:
condition: service_healthy
postgres:
image: postgres:10.1
mem_limit: 1500m
environment:
- POSTGRES_PASSWORD=apass
- POSTGRES_USER=auser
- POSTGRES_DB=adb
networks:
- mean
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 20s
timeout: 5s
retries: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment