Using docker-compose with CI - how to deal with exit codes and daemonized linked containers?

后端 未结 9 1248
故里飘歌
故里飘歌 2020-12-07 11:45

Right now our Jenkins agents generate a docker-compose.yml for each of our Rails projects and then run docker-compose up. The docker-compose.yml has a main \"web\" container

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 12:21

    Use docker wait to get the exit code:

    $ docker-compose -p foo up -d
    $ ret=$(docker wait foo_bar_1)
    

    foo is the "project name". In the example above, I specified it explicitly, but if you don't supply it, it's the directory name. bar is the name you give to the system under test in your docker-compose.yml.

    Note that docker logs -f does the right thing, too, exiting when the container stops. So you can put

    $ docker logs -f foo_bar_1
    

    between the docker-compose up and the docker wait so you can watch your tests run.

提交回复
热议问题