GitLab runner 无法通过 http 克隆存储库 [英] GitLab runner unable to clone repository via http

查看:83
本文介绍了GitLab runner 无法通过 http 克隆存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在测试环境中运行了 GitLab 的最新 docker 映像,但我遇到了 GitLab 运行器的问题.它无法通过 HTTP 链接进行克隆,产生以下消息:

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

我使用 --debug 标志运行 gitlab-runner 并使用它正在尝试的确切地址(使用完整的令牌),我可以很好地克隆存储库.我不知道为什么该服务无法克隆存储库.运行程序执行程序也配置为docker".也许该容器存在一些端口映射问题?

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?

推荐答案

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

I hypothesized the issue might have something to do with registering the runner as a docker container causing the localhost address not to resolve to the right machine (where I'm starting the runner); in this case it probably resolves to the container instead. Using the host's IP on the docker proxy interface (172.17.0.1 for me) or using the host's real address instead of "localhost" when registering the runner fixes the problem.

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

Here is a bit more detail on the problem as I understand it and a solution. The docker instance that's loaded up is like a (very) lightweight virtual machine. Docker configures a virtual network interface which you'll see if you run ifconfig from your host machine:

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 通信.

This is the IP address of the host machine on that interface. So, if you want the runner to be able to connect to the service that's running on that host machine, you can't point it to localhost/127.0.0.1 because, coming from inside the runner's instance, that will route to the runner's "VM", but GitLab is not running inside that runner "VM", it's on the host, so the runner is unable to communicate with GitLab.

解决办法是在docker接口(http://172.17.0.1/ci 对我来说),或者使用主机的公共 IP 或域名(如果你有一个并且可以公开访问).只是不要将它发送到 localhost 或 127.0.0.1,因为对于跑步者来说,它指向它的VM",而不是你的 GitLab 实例.

The solution is to register the runner to point to the host's virtual address on the docker interface (http://172.17.0.1/ci for me), or to use the host's public IP or a domain name if you have one and it's accessible publicly. Just don't send it to localhost or 127.0.0.1 because, to the runner, that points to its "VM", not your GitLab instance.

这篇关于GitLab runner 无法通过 http 克隆存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆