10

I have the latest docker image of GitLab running in a test environment and I'm running into an issue with the GitLab runner. It's unable to clone via the HTTP link, yielding the following message:

Running on runner-bd27e50b-project-1-concurrent-0 via machine...
Cloning repository...
Cloning into '/builds/my/awesome-project'...
fatal: unable to access 'http://gitlab-ci-token:xxxxxx@127.0.0.1/my/awesome-project.git/': 
    Failed to connect to 127.0.0.1 port 80: Connection refused

ERROR: Build failed with: exit code 1

I ran gitlab-runner with the --debug flag and used the exact address it was trying (with the token in-tact) and I could clone the repository just fine. I'm at a loss as to why the service is unable to clone the repository. The runner executor is configured as 'docker' as well. Maybe there is some port mapping issue into that container?

4

3 回答 3

9

I know this question is pretty old, but you can use slightly different approach (in case you are using docker runner with the same problem).

Run Gitlab under a domain name - it may be totally virtual, just make sure that all your VMs can resolve the domain name.

Then modify /etc/gitlab-runner/config.toml and add extra_hosts variable to the [runners.docker] section with value ["your_domain_name:ip_address"]. You can also add any other hosts you may need.

You can find more info on runner config at https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md

于 2016-03-02T22:59:33.267 回答
8

我假设这个问题可能与将跑步者注册为 docker 容器有关,导致 localhost 地址无法解析到正确的机器(我正在启动跑步者的地方);在这种情况下,它可能会解析为容器。在 docker 代理接口(对我来说是 172.17.0.1)上使用主机的 IP 或在注册运行器时使用主机的真实地址而不是“localhost”可以解决问题。

编辑:这是我理解的问题和解决方案的更多细节。加载的 docker 实例就像一个(非常)轻量级的虚拟机。Docker 配置了一个虚拟网络接口,如果您从主机运行 ifconfig,您将看到该接口:

user@pc:~> ifconfig
docker0   Link encap:Ethernet  HWaddr XXXX
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          ...

这是该接口上主机的 IP 地址。因此,如果您希望跑步者能够连接到该主机上运行的服务,则不能将其指向 localhost/127.0.0.1 因为来自跑步者的实例内部,它将路由到跑步者的 " VM”,但 GitLab 并未在该运行器“VM”内运行,它在主机上,因此运行器无法与 GitLab 通信。

解决方案是在 docker 接口上注册运行程序以指向主机的虚拟地址(对我来说是http://172.17.0.1/ci),或者使用主机的公共 IP 或域名(如果您有并且可以访问)公开。只是不要将它发送到 localhost 或 127.0.0.1,因为对于跑步者来说,它指向它的“VM”,而不是你的 GitLab 实例。

于 2015-11-30T20:57:55.967 回答
0

至于现在(最新版本的 gitlab - 9 及更高版本),您需要使用带有正确 ssl 证书的https 。
只要您使用 https://... 添加新的跑步者,一切都应该可以正常工作。

于 2017-08-03T00:09:08.223 回答