title: Docker-Compose: how to wait for other service to be ready?
body: <p>I have the following <strong>docker-compose</strong>, where I need to wait for the service <strong>jhipster-registry</strong> to be up and accepting connections before starting <strong>myprogram-app</strong>.</p>
  
  <p>I tried the healtcheck way, following the official doc <a href="https://docs.docker.com/compose/compose-file/compose-file-v2/" rel="noreferrer">https://docs.docker.com/compose/compose-file/compose-file-v2/</a> </p>
  
  <pre><code>version: '2.1'
  services:
      myprogram-app:
          image: myprogram
          mem_limit: 1024m
          environment:
              - SPRING_PROFILES_ACTIVE=prod,swagger
              - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
              - SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
              - SPRING_DATASOURCE_URL=jdbc:postgresql://myprogram-postgresql:5432/myprogram
              - JHIPSTER_SLEEP=0
              - SPRING_DATA_ELASTICSEARCH_CLUSTER_NODES=myprogram-elasticsearch:9300
              - JHIPSTER_REGISTRY_PASSWORD=53bqDrurQAthqrXG
              - EMAIL_USERNAME
              - EMAIL_PASSWORD
          ports:
              - 8080:8080
          networks:
            - backend
          depends_on:
            - jhipster-registry:
                "condition": service_started
            - myprogram-postgresql
            - myprogram-elasticsearch
      myprogram-postgresql:
          image: postgres:9.6.5
          mem_limit: 256m
          environment:
              - POSTGRES_USER=myprogram
              - POSTGRES_PASSWORD=myprogram
          networks:
            - backend
      myprogram-elasticsearch:
          image: elasticsearch:2.4.6
          mem_limit: 512m
          networks:
            - backend
      jhipster-registry:
          extends:
              file: jhipster-registry.yml
              service: jhipster-registry
          mem_limit: 512m
          ports:
              - 8761:8761
          networks:
            - backend
          healthcheck:
            test: "exit 0"
  networks:
    backend:
      driver: "bridge"
  </code></pre>
  
  <p>but I get the following error when running <code>docker-compose up</code>:</p>
  
  <pre><code>ERROR: The Compose file './docker-compose.yml' is invalid because:
  services.myprogram-app.depends_on contains {"jhipster-registry": {"condition": "service_started"}}, which is an invalid type, it should be a string
  </code></pre>
  
  <p>Am I doing something wrong, or this feature is no more supported? How to achieve this sync between services?</p>
  
  <p><strong>Updated version</strong></p>
  
  <pre><code>version: '2.1'
  services:
      myprogram-app:
          image: myprogram
          mem_limit: 1024m
          environment:
              - SPRING_PROFILES_ACTIVE=prod,swagger
              - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
              - SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
              - SPRING_DATASOURCE_URL=jdbc:postgresql://myprogram-postgresql:5432/myprogram
              - JHIPSTER_SLEEP=0
              - SPRING_DATA_ELASTICSEARCH_CLUSTER_NODES=myprogram-elasticsearch:9300
              - JHIPSTER_REGISTRY_PASSWORD=53bqDrurQAthqrXG
              - EMAIL_USERNAME
              - EMAIL_PASSWORD
          ports:
              - 8080:8080
          networks:
            - backend
          depends_on:
            jhipster-registry:
              condition: service_healthy
            myprogram-postgresql:
              condition: service_started
            myprogram-elasticsearch:
              condition: service_started
          #restart: on-failure
      myprogram-postgresql:
          image: postgres:9.6.5
          mem_limit: 256m
          environment:
              - POSTGRES_USER=myprogram
              - POSTGRES_PASSWORD=tuenemreh
          networks:
            - backend
      myprogram-elasticsearch:
          image: elasticsearch:2.4.6
          mem_limit: 512m
          networks:
            - backend
      jhipster-registry:
          extends:
              file: jhipster-registry.yml
              service: jhipster-registry
          mem_limit: 512m
          ports:
              - 8761:8761
          networks:
            - backend
          healthcheck:
            test: ["CMD", "curl", "-f", "http://jhipster-registry:8761", "|| exit 1"]
            interval: 30s
            retries: 20
            #start_period: 30s
  networks:
    backend:
      driver: "bridge"
  </code></pre>
  
  <p>The updated version gives me a different error, </p>
  
  <pre><code>ERROR: for myprogram-app  Container "8ebca614590c" is unhealthy.
  ERROR: Encountered errors while bringing up the project.
  </code></pre>
  
  <p>saying that the container of jhipster-registry is unhealthy, but it's reachable via browser. How can I fix the command in the healthcheck to make it work?</p>