Race condition between dependent service containers

Hi
I am new to circleCI and am using version 2. I have a condition where my primary container depends on a secondary service which in turn depends on another service ( MySQL instance.) From what I see in discussion can use dockerize so that my primary container can wait for MySQL or any other service to come up. But in my case how do I wait for one service MySQL container to be ready before my another service container starts up ?

If you are starting your containers using the docker array in a config.yml, then you can’t - I would expect they would start in parallel. However, if one of these containers depends on another, you could put a sleep or a connection test in that container.

The alternative is that you get your system running in Docker Compose, and then you can define dependencies between containers.

Hi
Thanks for the reply.

The alternative is that you get your system running in Docker Compose, and then you can define dependencies between containers.

I created compose and set up remote docker container. Problem is the primary container which I need to test is not able to communicate with the secondary service containers that I started with compose. I read about Accessing Services but did not get that. Any help or pointers will be appreciated. Sorry about discussing a separate problem in the same thread.

If you have your tests in the primary container, then you could use the primary container to make a Docker image of the tests, and then bring that up in Docker Compose. The test container will then join the network shared by your other containers, and they can communicate via TCP or HTTP, or you can run commands from the primary container using docker exec.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.