When using a GitLab Runner with a "docker" executor, the following build error occurs:
Running with gitlab-runner 10.7.0 (7c273476)
on main 80500676
Using Docker executor with image centos:latest ...
Pulling docker image centos:latest ...
Using docker image sha256:e934aafc22064b7322c0250f1e32e5ce93b2d19b356f4537f5864bd102e8531f for centos:latest ...
Running on runner-80500676-project-1-concurrent-0 via hostname-of-gitlab-runner-and-gitlab-server...
Cloning repository...
Cloning into '/builds/some-group-name/some-repository-name'...
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@hostname-of-gitlab-runner-and-gitlab-server/some-repository-name/some-repository-name.git/':
Could not resolve host: hostname-of-gitlab-runner-and-gitlab-server
ERROR: Job failed: exit code 1
It looks like the GitLab Runner is using the hostname of its Docker host as the FQDN or hostname of the Git server to pull the code from. This doesn't make sense, as it's not in any of the configuration files:
This is the GitLab configuration:
$ sudo cat /etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0
[[runners]]
name = "main"
url = "http://127.0.0.1:1337/"
token = "80500676b5518df3f3f3b1f772e20b"
executor = "docker"
[runners.docker]
tls_verify = false
image = "ubuntu:latest"
privileged = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
#extra_hosts = ["hostname-of-gitlab-runner-and-gitlab-server:actual-fqdn-of-gitlab-server-where-git-repo-is"]
[runners.cache]
This is the relevant configuration for external_url
in the GitLab server configuration:
$ sudo egrep '\bexternal_url\b' /etc/gitlab/gitlab.rb
##! For more details on configuring external_url see:
external_url = 'https://server:actual-fqdn-of-gitlab-server-where-git-repo-is'
# gitlab_pages['artifacts_server_url'] = nil # Defaults to external_url + '/api/v4'
This is the relevant configuration for host:
in the GitLab server's generated configuration:
$ sudo egrep -C 2 -n '^ host: ' /var/opt/gitlab/gitlab-rails/etc/gitlab.yml | head -n 5
11- gitlab:
12- ## Web server settings (note: host is the FQDN, do not include http://)
13: host: hostname-of-gitlab-runner-and-gitlab-server
14- port: 80
15- https: false
When I change hostname-of-gitlab-runner-and-gitlab-server
to actual-fqdn-of-gitlab-server-where-git-repo-is
, and run sudo gitlab-ctl reconfigure
, it gets reset.
If I edit gitlab.host
in /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
directory, and run sudo gitlab-ctl restart
without running sudo gitlab-ctl reconfigure
, it will stay intact.
Some unanswered questions are:
How can I permanently set the
gitlab.host
configuration value that gets generated in/var/opt/gitlab/gitlab-rails/etc/gitlab.yml
whensudo gitlab-ctl reconfigure
is run?Why does
gitlab.host
ingitlab.yml
keep getting set to the hostname of the GitLab server?