Answers: <p>If your application is going mad about the database being not available, you can insert a &quot;wait-for-port&quot; call at the beginning of the entrypoint. This only makes sense if you stick to docker-compose. But a better solution will be using Kubernetes.</p>
  <p>There are many implementations of wait-for programs around, but here is the Bitnami's Go binary:
  <a href="https://github.com/bitnami/wait-for-port" rel="nofollow noreferrer">https://github.com/bitnami/wait-for-port</a></p>
  <p>If you need run a sequence of jobs, here is the same question with good answers:
  <a href="https://stackoverflow.com/questions/40713573/how-to-run-containers-sequentially-as-a-kubernetes-job">https://stackoverflow.com/questions/40713573/how-to-run-containers-sequentially-as-a-kubernetes-job</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2021-12-08T09:53:11.633Z
Answers: My scenario is that I want to run a new container once the initial one has finished. Neither of those expose a port
Answers: science_buster
Answers: CC BY-SA 4.0
Answers: 2021-12-08T11:17:41.823Z
Answers: It looks like you need a plain shell script then. Docker-compose is not for such scenarios.
Answers: xy2
Answers: CC BY-SA 4.0
Answers: 2021-12-08T16:23:39.173Z
Answers: Well it used to have such functionalitites. Can you please elaborate on how kubernetes would help then? I really want to avoid using shellscripts again.
Answers: science_buster
Answers: CC BY-SA 4.0
Answers: 2021-12-08T16:29:23.943Z
Answers: Here is the same question with good answers:
  https://stackoverflow.com/questions/40713573/how-to-run-containers-sequentially-as-a-kubernetes-job
Answers: xy2
Answers: CC BY-SA 4.0
Answers: 2021-12-05T18:35:34.083Z
Answers: 2021-12-08T16:31:16.770Z
Answers: 2021-12-08T16:31:16.770Z
Answers: xy2
Body: <p>Currently I have a docker-compose.yaml which still contains <code>depends_on</code> with a <code>condition</code>.  Unfortunately this feature got removed in newer versions. There is already a discussion <a href="https://stackoverflow.com/questions/47710767/what-is-the-alternative-to-condition-form-of-depends-on-in-docker-compose-versio">here</a> where some alternatives like healthcheck and dockerize are mentioned. But I specifically liked about <code>depends_on</code> that you don't have to do this. Also helathchecks get executed periodically, and dockerize seems to only work by wating for ports to be availabkle. It was so easy to configure the flow of your containers in a way that one starts after another.</p>
  <p>So I was wondering if there is some alternative that is as easy as adding depends_on into your compose-file. Without having to setup anything else? Maybe there is some way to utilize <code>docker events</code>?</p>
  
Tags: <docker-compose><workflow>
Title: Lightweight alternative to healthchecks for flow-control in docker-compose
UserDisplayName: science_buster
ThreadText: # Lightweight alternative to healthchecks for flow-control in docker-compose
  
  (Asked by: username_0 on 2021-12-05)
  
  Currently I have a docker-compose.yaml which still contains `depends_on` with a `condition`. Unfortunately this feature got removed in newer versions. There is already a discussion [here](https://stackoverflow.com/questions/47710767/what-is-the-alternative-to-condition-form-of-depends-on-in-docker-compose-versio) where some alternatives like healthcheck and dockerize are mentioned. But I specifically liked about `depends_on` that you don't have to do this. Also helathchecks get executed periodically, and dockerize seems to only work by wating for ports to be availabkle. It was so easy to configure the flow of your containers in a way that one starts after another.
  
  So I was wondering if there is some alternative that is as easy as adding depends\_on into your compose-file. Without having to setup anything else? Maybe there is some way to utilize `docker events`?
  
  **Tags:** docker-compose, workflow
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-05. Score: 0 | Accepted answer
  
  If your application is going mad about the database being not available, you can insert a "wait-for-port" call at the beginning of the entrypoint. This only makes sense if you stick to docker-compose. But a better solution will be using Kubernetes.
  
  There are many implementations of wait-for programs around, but here is the Bitnami's Go binary:
  <https://github.com/bitnami/wait-for-port>
  
  If you need run a sequence of jobs, here is the same question with good answers:
  <https://stackoverflow.com/questions/40713573/how-to-run-containers-sequentially-as-a-kubernetes-job>
  
  > **Comments:**
  > **username_0**: My scenario is that I want to run a new container once the initial one has finished. Neither of those expose a port  
  > **username_1**: It looks like you need a plain shell script then. Docker-compose is not for such scenarios.  
  > **username_0**: Well it used to have such functionalitites. Can you please elaborate on how kubernetes would help then? I really want to avoid using shellscripts again.  
  > **username_1**: Here is the same question with good answers: https://stackoverflow.com/questions/40713573/how-to-run-containers-sequentially-as-a-kubernetes-job  
  
  ---
  
  