Terminate docker compose when test container finishes

前端 未结 6 1145
梦毁少年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:47

    I have tried the solution offered in this discussion but problem still in the case

    Case-1: docker-compose up -d

    You can use docker-compose up -d, test it by a test-runner then terminate by docker-compose down but the problem when you use docker-compose up -d is that you won't see the logs of the standard output anymore.

    Case-2: docker-compose up --exit-code-from a service

    You can view the docker logs if you use --exit-code-from that implies --abort-on-container-exit but the service won't send exit command when it is succeeded. Then you need to catch your container is finish tested before sending docker-compose down to stop them.

    One of the solution to see the logs before terminating them is using --tail=1000 -f

    docker-compose up -d
    docker-compose logs --tail=1000 -f test-runner
    docker-compose down
    exit $rc
    

    There is also a solution using nohup but you need to wait until process is completely finished then open the output logs file, so the above should be easier

提交回复
热议问题