Start Containers in Docker Compose in a Specified Order

I use Docker Compose Version 3 and I want to start a Docker container after another is already running. In the internet it is only explained how it works with Compose Version 2, but it doesn’t work with Version 3. Can somebody help me please?

The grown up orchestrators do not provide start order functionality.
You need to implement it yourself.

For swarm stack deployments, you will need to add something in your entrypoint script that blocks further processing of the entrypoint script, until a condition becomes true. The condition could be the response to a wget call to a http endpoint of the service it needs to wait for, or simply nc that tries to connect to a port (e.g. for a database). Back in my Swarm days, I used to add https://github.com/jwilder/dockerize to my images and use it to wait for the other service AND also to render template based configuration files. Though, I stopped using this approach, because Kubernetes simply provides better solutions for this problem.

Kubernetes on the other side, has the concept of initContainer, which allows a cleaner solution. While the original image can remain unchanged, the wait-for task can be perfomed by one or more initContainer(s). This is heavily used in the k8s world. It’s a pitty that Swarm does not provide initContainers.