I’m trying to register a gitlab-runner docker instance to my gitlab docker instance. Both run on the same host in the same docker network (called gitlab-net):
docker run --rm \ > -v /srv/gitlab-runner/config:/etc/gitlab-runner \ > --network gitlab-net \ > gitlab/gitlab-runner register \ > --non-interactive \ > --executor "docker" \ > --docker-image alpine:latest \ > --url "http://gitlab/" \ > --registration-token "thisIsMyToken" \ > --description "docker-runner" \ > --tag-list "docker,aws" \ > --run-untagged="true" \ > --locked="false" \ > --access-level="not_protected" \ > --docker-network-mode gitlab_gitlab-net Runtime platform arch=amd64 os=linux pid=7 revision=e95f89a0 version=13.4.1 Running in system-mode. ERROR: Registering runner... failed runner=thisIsMy status=couldn't execute POST against http://gitlab/api/v4/runners: Post https://my.domain:443/api/v4/runners: dial tcp 18.104.22.168:443: i/o timeout PANIC: Failed to register this runner. Perhaps you are having network problems
This is the docker run script for the gitlab instance:
docker run --detach \ --hostname my.domain \ --network gitlab-net \ --publish 443:443 \ --publish 80:80 \ --name gitlab \ --restart always \ --volume $GITLAB_HOME/config:/etc/gitlab \ --volume $GITLAB_HOME/logs:/var/log/gitlab \ --volume $GITLAB_HOME/data:/var/opt/gitlab \ gitlab/gitlab-ee:latest
As you can see, both containers run on the same network. When I SSH into a new container on the gitlab-net network, I can curl the gitlab instance by it’s hostname (which is the same as the container name, gitlab) without any problems:
curl -v http://gitlab * Trying 172.18.0.3:80... * TCP_NODELAY set * Connected to gitlab (172.18.0.3) port 80 (#0) > GET / HTTP/1.1 > Host: gitlab > User-Agent: curl/7.68.0 ...
So the networking between the two containers is working fine. In fact, the gitlab-runner container must have gathered some information from the gitlab container via network because it is trying to call it by it’s public domain/IP (… Post https://my.domain:443/api/v4/runners: dial tcp 22.214.171.124:443 …) which I didn’t give as an argument in the run command (only the local hostname of the gitlab container is mentioned there, gitlab).
How do I get the runner registration working? It seems like I have to “convince” the gitlab-runner container to not use the public address for it’s POST requests, but I have no idea how to achive this.