Terminate docker compose when test container finishes

前端 未结 6 1138
梦毁少年i
梦毁少年i 2021-01-30 16:56

I am currently running a docker-compose stack for basic integration tests with a protractor test runner, a nodejs server serving a web page and a wildfly server serving a java b

6条回答
  •  走了就别回头了
    2021-01-30 17:25

    You can use these docker-compose parameters to achieve that:

    --abort-on-container-exit Stops all containers if any container was stopped.

    --exit-code-from Return the exit code of the selected service container.

    For example, having this docker-compose.yml:

    version: '2.3'
    
    services:
      elasticsearch:
        ...
      service-api:
        ...
      service-test:
        ...
        depends_on:
          - elasticsearch
          - service-api
    

    The following command ensures that elasticsearch and service-api go down after service-test is finished, and returns the exit code from the service-test container:

    docker-compose -f docker-compose.yml up \
        --abort-on-container-exit \
        --exit-code-from service-test
    

提交回复
热议问题