Can somehow with docker or docker-compose run container B before container A stop?

docker-compose support trigger event or something like that?


1 Answer 1


If you mean make sure that container A does not execute and then exit then no. Docker containers will stop if the container crashes or if the main process exits.

However, if you are attempting to run container B and it is dependent on container A, I think the depends_on flag may be what you are looking for. This will allow you to ensure that service B will run after service A is started. However, you may need to add something to service A that ensures that it is ready before attempting to connect to it (e.g. a database).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.