Docker compose - 如何仅在所有容器都退出时停止所有容器?

时间:2021-06-17 13:24:48

标签: image docker docker-compose cypress

我创建了多个 cypress 容器,每个容器都运行一组测试。这些容器需要与协调器服务通信,这就是它们被链接的原因。当我运行 docker compose up 时,每个容器都会运行它的一组测试并以 0 或 1 退出,这取决于某些测试是否失败。运行测试工作正常。

我的问题是,只有当所有 cypress 容器都完成运行测试(以 0 或 1 退出)时,我怎么才能中止? --exit-code-from SERVICE 不起作用,因为我不想在 cypress 服务之一退出时中止,而是在所有服务都退出时中止。

这是我的 docker-compose.yml 文件示例

version: '3'
networks:
    default:
      external:
        name: bridge
  
services:
    orchestrator:
        image: test        
        network_mode: bridge
        ports:
            - 1234:1234     
        
    cypress1:
        image: cypress1
        container_name: cypress1
        build:
            context: ./
        links:
            - orchestrator
        ports:
            - '5555:5555'
        network_mode: bridge
        environment:
        command: npx cypress run --spec "**/test.ts"
  
   cypress2:
        image: cypress2
        container_name: cypress2
        build:
            context: ./
        links:
            - orchestrator
        ports:
            - '5555:5555'
        network_mode: bridge
        environment:
        command: npx cypress run --spec "**/test2.ts"

0 个答案:

没有答案
相关问题