No route to host occurs between services started by dockercomposite.

  docker, question

Two spring cloud project images, one is config Configuration Center and the other is eureka Service Governance.
The configuration parameters of eureka should be taken from config, and the config address in eureka is the config host address and the corresponding port.

Starting with dockercompound, noroutohost appears in eureka log and config service cannot be accessed.

But! I tried to start two tasks through docker run, and there was no problem.

Does a great god know why and how to solve it?

1.15 update
I tried two services to write two docker-compose files respectively to start, as a result, eureka changed an exception when accessing config, connection refused

  • It is estimated that the service is not ready yet.
  • HypothesisService aDepend onService b,docker composeIn the process of starting the service, it can ensure thatService bContainer precedesService aThe container starts, but cannot be guaranteed directly.Service bPrior toService aReady. such asService bThe container will not be ready until one second after it is started, andService aIt will be ready 200 milliseconds after the container is started, so even ifService bIt’s no use starting it first.
  • Control startup order in Compose