I'm having a problem with the ordering of my Docker services in terms of how they are setup. Effectively I have five services: api (a Django Rest Framework application), db (a PostgreSQL database), elasticsearch (an Elasticsearch service), Kibana, and APM for logging.
Effectively, I need Elasticsearch to be spun up before the apm service can begin doing it's thing - but the ordering is such that Elasticsearch needs to finish before APM and Kibana can begin doing there thing.
Here is my docker-compose.yml
file and all the relevant dependencies:
version: "3"
services:
api:
build:
context: api
command: python3 manage.py runserver 0.0.0.0:8000
env_file: api/.env
volumes:
- ./api:/usr/src/app
ports:
- 8000:8000
- 6900:6900
depends_on:
- db
db:
build: docker/db
environment:
- POSTGRES_DB=************
- POSTGRES_USER=dbaccount
- POSTGRES_PASSWORD=dbpassword
ports:
- 5432:5432
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.5.1
ports:
- 9200:9200
- 9300:9300
environment:
- discovery.type=single-node
- cluster.routing.allocation.disk.threshold_enabled=false
kibana:
image: docker.elastic.co/kibana/kibana:6.5.1
ports:
- 5601:5601
depends_on:
- elasticsearch
apm:
image: docker.elastic.co/apm/apm-server:6.5.1
volumes:
- ./docker/apm/apm-server.yml:/usr/share/apm-server/apm-server.yml
depends_on:
- elasticsearch
ports:
- 8200:8200
Effectively the running order causes a generic Linux chroot exit code of "1" on the APM service, and requires a manual "docker-compose apm restart" for everything to get going...
Is there a way to wait for one service to fully "up" before "upping" another?