How does the gitlab-runner wait for services?

Hi all,

I have trouble understanding how the gitlab-runner handles dependencies on services. I have a job that has a dependency on some service, which itself has again another dependency on a different service (e.g. a database), so I end up with the following configuration:

  image: some_image
    - postgres
    - some_service #depends on postgres
    - run-test-against-some-service

How does gitlab-runner know when a service is fully started? I found something in the code that looks like a second container is started that uses netcat to check if some port opened, but how does gitlab-runner know which port to check?
Also, is it guaranteed that the services are started and waited for in the defined order? i.e., is it safe to assume that when the container for “some_service” is started, that the postgres DB is already started and available?

After some more experiments I am under the impression, that the first service (i.e., in this example the database) isn’t even linked to the second service. Is this correct?
How could something like this be implemented with GitLab CI?


1 Like

I am just running into the exact same issue. The service and the database are connected to the “bridge”-network, but i also think that they are not linked.
Are there any solutions for this problem?

Edit: i found an 9 month old open issue for this at