Gitlab runner docker Could not resolve host

后端 未结 4 698
半阙折子戏
半阙折子戏 2021-01-04 17:32

Im using 2 containers on my Ubuntu OS: Gitlab-ce and gitlab-runner

Containers names are: gitlab_gitlab_1 and gitlab_gitlab-runner_1

I

4条回答
  •  感动是毒
    2021-01-04 18:32

    In case this helps others looking for this..

    Same problem but GitLab and GitLab Runner run on different machines in LAN. DNS is working and ping gitlab works, except inside dockers:

    Reproduce problem:

    $ sudo docker run -it alpine ping gitlab
    ping: bad address 'gitlab'
    ^C
    

    But works with DNS given:

    $ sudo docker run -it --dns=172.168.0.1 alpine ping gitlab
    PING gitlab (172.168.0.5): 56 data bytes
    64 bytes from 172.168.0.5: seq=0 ttl=63 time=0.536 ms
    ^C
    

    Config actual LAN DNS for docker.

    Edit /etc/docker/daemon.json on the GitLab Runner (file did not exist yet) with contents:

    {
        "dns": ["172.168.0.1", "1.1.1.1"]
    }
    

    Test again, now OK:

    $ sudo docker run -it --dns=172.168.0.1 alpine ping gitlab
    PING gitlab (172.168.0.5): 56 data bytes
    64 bytes from 172.168.0.5: seq=0 ttl=63 time=0.455 ms
    64 bytes from 172.168.0.5: seq=1 ttl=63 time=0.905 ms
    ^C
    

    If this is not how its supposed to be done, i'd be happy to hear.
    If this problem shouldnt aught to exist in the first place, i'd be happy to hear as well. I was surprised to not find much references online to this problem for GitLab Runner..

提交回复
热议问题