Access runner container from compose container in gitlab-ci

Viewed 42

I'm using gitlab-ci runners with docker executor.
In my test job, I spin up a test environment using docker compose and then run my tests.
My tests spin up an HTTP server and execute tests against it.

Some container in the compose network need access to the HTTP server running in the CI runner, but I couldn't figure out how.

setup_test_services:
  image: docker:git
  stage: setup
  services:
    - docker:dind
  script:
    ...
    - docker compose --env-file .env up --wait
    - yarn install
    - yarn test
  variables:
    ...
    FF_NETWORK_PER_BUILD: "true"
    SERVICE_URL: http://build:9999

The compose services are running in the default network and I'm using FF_NETWORK_PER_BUILD to connect the runner network to the docker compose network.
The container can't access my tests HTTP server though.
Please note that I'm using docker:dind service.
What am I doing wrong?

https://docs.gitlab.com/runner/executors/docker.html#create-a-network-for-each-job

0 Answers
Related