title: How to start service only when other service had completed?
body: <p>Using compose I want to start a service only after another service has exited with code 0.</p>
  
  <p>I have mutiple needs for this functionality. The basic need is where I have:</p>
  
  <ul>
  <li>database service</li>
  <li>database migration service</li>
  <li>application service</li>
  </ul>
  
  <p>The database service will start an empty database. My app needs it's schema setup in the database so I have a second service which will do this when it is run. When it is done this service will exit successfully - I can see this in my docker compose log file:</p>
  
  <blockquote>
    <p>webservices_kong-migration_1 exited with code 0</p>
  </blockquote>
  
  <p>I do not want the application service to start until <strong>after</strong> the database migration has completed.</p>
  
  <p>I have the following in my docker-compose file for the application service:</p>
  
  <blockquote>
  <pre><code>depends_on:
    kong-database:
      condition: service_healthy
    kong-migration:
      condition: service_started
  </code></pre>
  </blockquote>
  
  <p>I know this is wrong because I can see in my docker-compose log that the application is started after the migration has started but before it has completed, causing the application to fail.</p>
  
  <p>(I have been taking <a href="https://github.com/Kong/docker-kong/blob/master/compose/docker-compose.yml" rel="noreferrer">https://github.com/Kong/docker-kong/blob/master/compose/docker-compose.yml</a> as an example)</p>
  
  <p>Does docker-compose have functionality to do this or should I be considering another method?</p>