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 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?

1 Answer 1


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

  • My scenario is that I want to run a new container once the initial one has finished. Neither of those expose a port Dec 8, 2021 at 9:53
  • It looks like you need a plain shell script then. Docker-compose is not for such scenarios.
    – xy2
    Dec 8, 2021 at 11:17
  • 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. Dec 8, 2021 at 16:23
  • Here is the same question with good answers: stackoverflow.com/questions/40713573/…
    – xy2
    Dec 8, 2021 at 16:29

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.