首页 文章

GitLab runner无法通过http克隆存储库

提问于
浏览
5

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

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,并使用了它正在尝试的确切地址(带有令牌),我可以克隆存储库就好了 . 我也是'm at a loss as to why the service is unable to clone the repository. The runner executor is configured as '码头 Worker . 也许有一些端口映射问题进入该容器?

3 回答

  • 0

    我知道这个问题很老了,但你可以使用稍微不同的方法( in case you are using docker runner 也有同样的问题) .

    在域名下运行Gitlab - 它可能完全是虚拟的,只需确保所有VM都可以解析域名 .

    然后修改 /etc/gitlab-runner/config.toml 并将 extra_hosts 变量添加到 [runners.docker] 部分,其值为 ["your_domain_name:ip_address"] . 您还可以添加您可能需要的任何其他主机 .

    你可以在https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md找到关于runner config的更多信息

  • 5

    我假设这个问题可能与将运行器注册为docker容器有关,导致localhost地址无法解析到正确的机器(我正在启动运行器);在这种情况下,它可能会解析为容器 . 在docker代理接口上使用主机的IP(对我来说是172.17.0.1)或在注册运行器时使用主机的真实地址而不是“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),或者使用可公开访问的主机's public IP or a domain name if you have one and it' . 只是不要将它发送到localhost或127.0.0.1,因为对于跑步者来说,它指的是"VM",而不是你的GitLab实例 .

  • 8

    至于现在(gitlab的最新版本 - 9 and upwards ),你需要使用 https 和正确的ssl证书 .
    一旦你用https://添加新的跑步者...所有应该工作得很好 .

相关问题