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
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.