0

I using docker-compose in version 3.3 and I want to wait for a container with spring app is up and after that other containers with spring boot app should be started. I tried with health check but it's doesn't work. This is my docker-compose looks like:

version: '3.3'
services:
  eureka:
    build: ./eureka
    ports:
      - 8761:8761
    networks:
      - spring-cloud-network
    environment:
      - SPRING_ZIPKIN_BASEURL=http://zipkin:9411
    depends_on:
      - zipkin
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8761"]
      interval: 10s
      timeout: 10s
      retries: 5
  zipkin:
    build: ./zipkin
    ports:
      - 9411:9411
    networks:
      - spring-cloud-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9411"]
      interval: 10s
      timeout: 10s
      retries: 5

Is it possible to achieve what I want?

Mateusz Sobczak
  • 1,551
  • 8
  • 33
  • 67
  • 1
    You could create a bash (for example) script that checks the readiness-check endpoints of other containers in a loop (for example) and launches the jar only if other are started. And then you use this script as entrypoint of your spring-boot app image. – Michał Krzywański Apr 16 '20 at 07:09
  • @michalk thank you for your answer, so how to pass link to zipkin container into eureka entrypoint sh script? – Mateusz Sobczak Apr 16 '20 at 08:20
  • 1
    you can use environment variables for example. The script will pick values from the environment when then container is being launched. – Michał Krzywański Apr 16 '20 at 08:27
  • This is a perfect use case for adding Kubernetes! – Jose Gleeson Jan 11 '23 at 14:17

1 Answers1

0

According to official documentation (https://docs.docker.com/compose/startup-order/) it seems that this is not possible, and they also explain why that is, while also providing some workarounds.