Docker组合等待没有睡眠命令

我读了很多类似的话题。 例如: Docker Compose在启动Y之前等待容器X

所以,我试图实现只有使用撰写和健康检查的等待。

我只有一个docker-compose文件。 有一个应用程序的部分和为这个应用程序的testing。

testing(服务)只能在app(jar,db等)准备好的时候执行。 另外testing(服务)执行后,我想通过$获得执行状态?

所以我的撰写文件是下一个:

version: "2.1" networks: myNetwork: services: rabbitmq: ... networks: - myNetwork healthcheck: test: ["CMD", "rabbitmqctl", "status"] interval: 100s timeout: 10s retries: 10 app: ... depends_on: rabbitmq: condition: service_healthy networks: - myNetwork healthcheck: test: ["CMD", "wget", "http://localhost:8080/ping"] interval: 100s timeout: 10s retries: 10 tests: build: context: . dockerfile: TestDocker depends_on: app: condition: service_healthy networks: - myNetwork 

我试图运行:

 docker-compose up -d app && docker-compose run tests; 

要么

 docker-compose run tests 

但是docker-compose run tests不等条件:service_healthy; (app和rabbitmq容器启动,但service_healthy没有被检查);

这是问题所在。

当我做这样的事情时:

  docker-compose up -d app && sleep 20 && docker-compose run tests; 

那么是否有任何可能做睡觉或等待,为了命令:docker – compose run tests