将GitLab跑步者与GitLab

时间:2017-09-22 13:16:43

标签: docker gitlab gitlab-ci-runner

GitLab当前在给定主机上作为容器运行,我正在尝试在另一个容器中的同一主机上设置GitLab runner:

GitLab脚本(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脚本:

[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正在使用HTTPS运行。

现在,当我尝试运行gitlab_runner.sh时,我收到以下错误:

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 

我可以看到172.17.0.2只是GitLab IP,如下面Rancher UI所示:

enter image description here

1 个答案:

答案 0 :(得分:2)

我终于开始工作了。我将容器重命名为gitlab.abc.net并将 gitlab runner 脚本的配置更新为以下内容:

[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