Local Gitlab cicd failed 'fatal: unable to access...Could not resolve host:...' with linux runner

I am trying to test my python project and run via gitlab. I have installed runner on my ubuntu notebook and complete registered with local gitlab server. Thus, got 2 seperate machine one runner and another one is gitlab server. Both machine can communicate each other. Notebook(192.168.100.10) ---- GitLab(172.16.10.100)

Once I commit test, my job failed with message below;

Reinitialized existing Git repository in /builds/dz/mytest/.git/
 fatal: unable to access 'http://gitlab.lab01.ng/dz/mytest.git/': Could not resolve host: gitlab.lab01.ng
Uploading artifacts for failed job
 ERROR: Job failed: exit code 1

From my notebook cli, i can ping gitlab server ip but not the host name even curl also doesnt know the hostname. I believe this is something to do with the dns that cannot resolved. I add hostname in my notebook /etc/hosts , i can ping hostname but still failed run job with the same message. I have tried people suggest add below inside gitlab-runner config.toml, thus I add below in config.toml (Not sure if this is correct to add in config.toml)

[[runners]]
dns_search = [""] 

Still failed and got the same message could not resilve host. What can I do on my notebook setting/runner? I dont have admin access to gitlab to check further. Anyone face the same problem. Appreciate help and support thank you.

--For information I have tried testing the runner on my notebook with public gitlab (gitlab.com) and I can run the job successfully without any error message--

1 answer

  • answered 2020-06-07 05:13 Lukman

    I'm assuming you are using docker as the executor for your GitLab runner since you did not specify it in your question. Docker executor does not share the /etc/hosts of the host machine but you can use extra_hosts parameter inside your config.toml to let the runner container know about the custom hostname:

    [runners.docker]
    extra_hosts = ["gitlab.lab01.ng:172.16.10.100"]