Race condition between dependent service containers


#1

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 ?


#2

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.


#3

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.


#4

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.


#5

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