本文介绍了如何让Docker Gitlab CI转换程序在其主机上访问Git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Gitlab在我们的内部网络上设置,位于

Gitlab is setup on our internal network at http://gitlab

Docker容器在相同的机器无法连接到它。

Docker containers on the same machine can't connect to it.

如何配置docker,以便它知道gitlab是它的父代?

How do I configure docker so that it knows gitlab is its parent?

当Gitlab CI尝试运行一个构建(Docker容器内)时,问题就显现出来:

The problem exhibits itself when Gitlab CI attempts to run a build (inside a Docker container):

我尝试将网络的DNS服务器添加到 / etc中的 DOCKER_OPTS / default / docker 无效。

I've tried adding the network's DNS servers to DOCKER_OPTS in /etc/default/docker to no avail.

推荐答案

根据,您可以尝试使用 extra_hosts param在您的GitLab CI赛跑者。
/etc/gitlab-runner/config.toml

According to the GitLab CI Runner Advanced configuration, you can try to play with the extra_hosts param in your GitLab CI runner.In /etc/gitlab-runner/config.toml :

[[runners]]
  url = "http://gitlab/ci"
  token = "TOKEN"
  name = "my_runner"
  executor = "docker"
  [runners.docker]
    host = "tcp://<DOCKER_DAEMON_IP>:2375"
    image = "..."
    ...
    extra_hosts = ["gitlab:192.168.0.39"]

有了这个例子, git将尝试从 gitlab 克隆,它将使用 192.168.0.39 作为此主机名的IP。

With this example, when inside the container running the test git will try to clone from gitlab, it will use the 192.168.0.39 as IP for this hostname.

这篇关于如何让Docker Gitlab CI转换程序在其主机上访问Git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 19:23