Docker Community Forums

Share and learn in the Docker community.

"depends_on" not being followed in Docker compose

docker

(Harshintentionet) #1

I have a docker-compose file for some containers:

version: "3"
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.1.1
    ports:
      - "9200:9200"
    environment:
      DISCOVERY_TYPE: single-node
  collector:
    image: jaegertracing/jaeger-collector
    ports:
      - "14267:14267"
    environment:
      SPAN_STORAGE_TYPE: elasticsearch
      ES_SERVER_URLS: http://elasticsearch:9200
    depends_on:
      - elasticsearch
  agent:
    image: jaegertracing/jaeger-agent
    ports:
      - "5775:5775/udp"
    depends_on:
      - collector
      - elasticsearch
    environment:
      COLLECTOR_HOST_PORT: collector:14267

I want the elasticsearch to be the first container to be started(attempted), but collector is always the first container to be started. I saw this depends_on reference which says docker will only start the service in given order but the service may actually be available in a different order, but I am also seeing the message in this order always:
Creating network jaeger_default
Creating service jaeger_collector
Creating service jaeger_agent
Creating service jaeger_elasticsearch
Seems the depends_on attribute is being ignored, or are the messages printed when the service has actually started rather than when docker started attempting to start that service?


(Harshintentionet) #2

I was using docker stack deploy which ignores the depends_on attribute, works with docker-compose