Connect CI Runner to Docker network
Summary
I have the following configuration:
dockered gitlab (named gitlab) dockered gitlab-ci-multirunner (linked to gitlab and named gitlab-runners).
┌──────────────────────┐ ┌─────────┐
│ 172.12.x.x │ │172.13.x.│
┌┴──────────┬┬──────────┴┐┌┴─────────┴┐
│ GitLab ││ GitLab ││ GitLab │
│ ││ Runners ││ Runners │
│ ││ ││ │
└───────────┘└───────────┘└───────────┘
│ │ │ ▲
│ │ │ ╱
│ │ │ ╱
│ │ ▼ ╱
───────┴────────────┴────────────────────
I successfully registered a runner into gitlab, but when I try to run a build I cannot manage to connect the docker container of the project spawned by the gitlab-runners to my gitlab docker; therefore when the project docker tries to clone the project, the runner is not able to resolve the name http://gitlab/ I tried to use the parameter -links=["network-name:gitlab"] in the toml file of my runner, but this leads to:
API error (500) Could not get container for <network name>.
I also tried to use the extra_hosts parameter and to write the IP address of my gitlab container (this is a solution that I have found in two issues on this repo). Unfortunately, since the two containers are not in the same network this leads to a time out.
Steps to reproduce
Here is my docker compose: version: '2'
services:
gitlab:
container_name: 'gitlab'
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlab'
ports:
- '80:80'
- '443:443'
- '2222:22'
expose:
- 80
- 443
- 2222
volumes:
- '/docker/gitlab/conf:/etc/gitlab'
- '/docker/gitlab/logs:/var/log/gitlab'
- '/docker/gitlab/data:/var/opt/gitlab'
networks:
- mynet
gitlab-runners:
container_name: 'gitlab-runners'
image: 'gitlab/gitlab-runner:latest'
restart: always
volumes:
- '/srv/gitlab-runnes:/etc/gitlab-runner'
- '/var/run/docker.sock:/var/run/docker.sock'
privileged: false
networks:
- mynet
gitlab-runners-data:
external: true
networks:
mynet:
external: true
- mynet is a simple bridge network I created.
- multi runner has been setup so that there is a specific runner for a project that runs in docker mode.
Actual behavior
The containers generated by the multi-runner are in a different logical network, therefore the \gitlab name or its IP address are either not resolvable nor reachable.
Expected behavior
I should be able to connect the containers created by the multi-runner in the same docker network of my gitlab instance.
Environment description
- custom installation on Centos 7
- docker 1.12.2
- kernel 3-10.0-327.el7.x86_64
Used GitLab Runner version
gitlab-ci-multi-runner 1.7.1