I have a docker-compose with 3 services: config-server, cpo-events and cpo-executor. I want that the services start only when config-server is ready because the services need the config files that are in config-server service.
version: '3.7' services: config-server: container_name: cup-config-server image: cup-config-server:1.0.0 expose: - 8888 ports: - 8888:8888 networks: - spring-cloud-network healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8888/cpo-executor/dev"] interval: 30s timeout: 10s retries: 5 cpo-events: container_name: cpo-events-kafka image: cpo-events-kafka:1.0.0 expose: - 8878 ports: - 8878:8878 networks: - spring-cloud-network depends_on: - config-server links: - config-server cpo-executor: container_name: cpo-executor image: cpo-executor:1.0.0 expose: - 8879 ports: - 8879:8879 networks: - spring-cloud-network depends_on: - config-server links: - config-server networks: spring-cloud-network: driver: bridge
Depends_on, links, healthcheck, nothing is guaranteeing the two services(cpo-executor, cpo-event) to start only after config-server is ready.
Source: Docker Questions