add hosts redirection in docker

后端 未结 2 770
粉色の甜心
粉色の甜心 2021-02-08 21:38

I use gitlab in a Virtual machine . And I will use gitlab-ci (in the same VM), with docker .

For access to my gitlab, I use the domain git.local ( redirect to my VM on m

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-08 22:01

    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://localhost/ci"
      token = "TOKEN"
      name = "my_runner"
      executor = "docker"
      [runners.docker]
        host = "tcp://:2375"
        image = "..."
        ...
        extra_hosts = ["localhost:192.168.0.39"]
    

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

提交回复
热议问题