Issue connecting GitLab runner with GitLab

Viewed 4113

GitLab is currently running on a given host as container and i am trying to setup GitLab runner on the same host in another container:

GitLab script (GitLab version: 9.3.9):

[root@rado1 gitlab_runner]# cat gitlab.sh
#!/bin/bash
sudo docker run --detach \
     --hostname gitlab.example.com \
     --publish 443:443 --publish 80:80 --publish 2222:22 \
     --name gitlab \
     --restart always \
     --volume /mnt/data/gitlab/config:/etc/gitlab \
     --volume /mnt/data/gitlab/logs:/var/log/gitlab \
     --volume /mnt/data/gitlab/data:/var/opt/gitlab \
     gitlab/gitlab-ce:latest

GitLab Runner script:

[root@rado1 gitlab_runner]# cat gitlab_runner.sh
docker run --name gitlab-ci-multi-runner -d --restart=always \
  --volume /mnt/data/gitlab/gitlab-runner:/home/gitlab_ci_multi_runner/data \
  --env='CI_SERVER_URL=http://gitlab/ci' --env='RUNNER_TOKEN=6cE9HefxGFfbAdadS4eT' \
  --env='RUNNER_DESCRIPTION=runnerA' --env='RUNNER_EXECUTOR=shell' \
  --link gitlab \
  sameersbn/gitlab-ci-multi-runner:1.1.4-7

GitLab is running on HTTPS.

Now when i try running gitlab_runner.sh, i get the following error:

ERROR: Registering runner... failed                 runner=6cE9Hefx 
status=couldn't execute POST against http://gitlab/ci/api/v1/runners/register.json: 
Post http://gitlab/ci/api/v1/runners/register.json: 
dial tcp 172.17.0.2:80: getsockopt: connection refused
PANIC: Failed to register this runner. Perhaps you are having network problems 

I can see that 172.17.0.2 is GitLab IP only as shown below in Rancher UI:

enter image description here

1 Answers

I finally got it working. I renamed the container to gitlab.abc.net and updated the config for gitlab runner script to the following:

[root@rado1 gitlab_runner]# cat gitlab_runner.sh
docker run --name gitlab-ci-multi-runner -d --restart=always \
  --volume /mnt/data/gitlab/gitlab-runner:/home/gitlab_ci_multi_runner/data \
  --env='CI_SERVER_URL=https://gitlab.abc.net/ci' --env='RUNNER_TOKEN=6cE9HefxGFfbAdadS4eT' \
  --env='RUNNER_DESCRIPTION=runnerA' --env='RUNNER_EXECUTOR=shell' \
  --link gitlab.abc.net \
  sameersbn/gitlab-ci-multi-runner:1.1.4-7
Related