From f5821bd1154889e866e3a02188b585759f2b71d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Fri, 30 Oct 2020 13:51:40 +0100 Subject: [PATCH] local_docker: Fix races between the containers This change will make docker-compose wait for both the redis and the postgres container before starting the other services. related #6792 --- .../roles/local_docker/templates/docker-compose.yml.j2 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/installer/roles/local_docker/templates/docker-compose.yml.j2 b/installer/roles/local_docker/templates/docker-compose.yml.j2 index 03bb530485d0..767ea70a6158 100644 --- a/installer/roles/local_docker/templates/docker-compose.yml.j2 +++ b/installer/roles/local_docker/templates/docker-compose.yml.j2 @@ -1,5 +1,5 @@ #jinja2: lstrip_blocks: True -version: '2' +version: '3' services: web: @@ -163,6 +163,9 @@ services: https_proxy: {{ https_proxy | default('') }} no_proxy: {{ no_proxy | default('') }} command: ["/usr/local/etc/redis/redis.conf"] + healthcheck: + test: ["CMD-SHELL", "redis-cli -s /var/run/redis/redis.sock ping"] + interval: 10s volumes: - "{{ docker_compose_dir }}/redis.conf:/usr/local/etc/redis/redis.conf:ro" - "{{ docker_compose_dir }}/redis_socket:/var/run/redis/:rw" @@ -176,6 +179,9 @@ services: image: {{ postgresql_image }} container_name: awx_postgres restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "pg_isready -U {{ pg_username }}"] + interval: 10s volumes: - "{{ postgres_data_dir }}/10/data/:/var/lib/postgresql/data:Z" environment: