Reference
https://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y
Questions
I am using rabbitmq and a simple python sample from here together with docker-compose. My problem is that I need to wait for rabbitmq to fully started. From what I searched so far, I don’t know how to wait with container x ( in my case worker ) until y (rabbitmq) is started.
Answer
Since docker-compose file format 2.1 you can define healthchecks.
Now I test if the management page of the rabbitmq-container is available. If curl finishes with exitcode 0 the container app (python pika) will be started and publish a message to hello queue. Its now working (output).
Docker Tutorials Fundamental To Advanced-2021 Crash Course:- https://bit.ly/3hOIbTB
- Implementing Managed IT Services: A Step-by-Step Guide - August 30, 2024
- DevOps Foundation Certification - August 29, 2024
- SRE Foundation Certification - August 29, 2024