Answers: <p>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.</p>
  
  <p>However, if you are attempting to run container B and it is dependent on container A, I think the <a href="https://docs.docker.com/compose/compose-file/#depends_on" rel="nofollow noreferrer">depends_on</a> 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).</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-01-23T14:53:52.393Z
Answers: 2020-01-23T14:53:52.393Z
Answers: Wesley Rolnick
Body: <p>Can somehow with docker or docker-compose run container B before container A stop?</p>
  
  <p>docker-compose support trigger event or something like that?</p>
  
  <p>Cheers</p>
  
Tags: <docker><docker-compose>
Title: docker-compose run container before other container stop
UserDisplayName: pioupiou
ThreadText: # docker-compose run container before other container stop
  
  (Asked by: username_0 on 2020-01-23)
  
  Can somehow with docker or docker-compose run container B before container A stop?
  
  docker-compose support trigger event or something like that?
  
  Cheers
  
  **Tags:** docker, docker-compose
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-23. Score: 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](https://docs.docker.com/compose/compose-file/#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).
  
  
  ---
  
  