From 3dcf2df553c5931a8e5c9651f77503b48c6f5673 Mon Sep 17 00:00:00 2001 From: meganemura Date: Sun, 15 Apr 2018 23:09:36 +0900 Subject: [PATCH] Add healthcheck container To make certain of runnning database containers. --- docker-compose.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d278344f..bddcaad6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.3' services: postgresql: image: postgres:9.5.12 @@ -6,9 +6,28 @@ services: POSTGRES_PASSWORD: "" ports: - "5432:5432" + healthcheck: + test: pg_isready -U postgres + start_period: 10s + interval: 10s + timeout: 30s + retries: 3 mysql: image: mysql:5.7 environment: MYSQL_ALLOW_EMPTY_PASSWORD: "yes" ports: - "3306:3306" + healthcheck: + test: mysqladmin -h 127.0.0.1 -uroot ping + start_period: 15s + interval: 10s + timeout: 30s + retries: 3 + healthcheck: + image: busybox + depends_on: + postgresql: + condition: service_healthy + mysql: + condition: service_healthy