Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dependencies to be brought down after 'run' #6190

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@imrook
Copy link

imrook commented Sep 13, 2018

Use case: Using docker-compose run --rm -p $BUILD_NUM in a CI environment to bring up all dependencies and run a set of tests and return an exit code reflecting the result of the test process.

Problem: Dependencies are left running after the container running the tests has terminated. Something similar to the following block must be used to ensure the desired behavior of stopping and removing all containers and returning the exit code from the test container.

docker-compose run --rm -p $BUILD_NUM app scripts/run_tests.sh
exit_code = $?
docker-compose down
exit $exit_code

This PR allows the above to be done with the following line:

docker-compose run --rm --rm-deps -p $BUILD_NUM app scripts/run_tests.sh
Add `--rm-deps` flag to `run` command.
When the flag is passed a `down` is performed after the one-off container exits.

Signed-off-by: Jason Noble <jason.noble@wpengine.com>
@shin-

This comment has been minimized.

Copy link
Contributor

shin- commented Sep 13, 2018

Hi @imrook - Thank you for your contribution!

In the future please create an issue first to lay out the problem and how you're looking to solve it so we can validate the design. 👼

My primary concern here is that the exit code for docker-compose run --rm-deps app scripts/run_tests.sh will only be 0 if both the run operation and the down operation are successful, so you're losing a ton of information you would have otherwise had. Your first snippet, while longer, is objectively better code if you care about the container's exit code.
I think in line with the UNIX philosophy principles, each Compose subcommand should do one thing and do it well, and the --rm-deps flag most certainly runs contrary to this principle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.