patterndockerMinor
GitLab Runner is using its Docker host's hostname as Git server FQDN/hostname
Viewed 0 times
dockergitlabitsrunnerhostusinghostnamegitserverfqdn
Problem
When using a GitLab Runner with a "docker" executor, the following build error occurs:
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:
This is the relevant configuration for
This is the relevant configuration for
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 1It 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 serverSolution
Neil, it's because the
When you'll look on the full comment before the
In the default
When you try to set the value with:
then the
In most cases the hostname of the server where GitLab is installed will be the same as the hostname that the server is accessible with. In some cases - including yours - the
So the solution seems to be:
This should set the proper values in
= sign in your /etc/gitlab/gitlab.rb file.When you'll look on the full comment before the
external_url line, you'll see a link to the documentation:## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://gitlab.example.com'In the default
gitlab.rb file (just after installing the Omnibus GitLab package) and also in the linked documentation you can see, that the external_url value is assigned without the = sign. It's done like that because the external_url is a method, not a variable. So here you're not assigning the value, but calling the method with this value. Ruby allows to call a method without brackets around the arguments, and this is a commonly used pattern when designing a DSLs based on Ruby.When you try to set the value with:
external_url = 'https://server:actual-fqdn-of-gitlab-server-where-git-repo-is'then the
external_url method is not receiving any argument and in that case Omnibus GitLab falls back to a default value which is based on host's hostname.In most cases the hostname of the server where GitLab is installed will be the same as the hostname that the server is accessible with. In some cases - including yours - the
external_url needs to be set explicitly.So the solution seems to be:
- Change
external_url = 'URL_HERE'toexternal_url 'URL_HERE'
- Execute
sudo gitlab-ctl reconfigure
This should set the proper values in
gitlab.yml file and resolve your problems.Code Snippets
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://gitlab.example.com'external_url = 'https://server:actual-fqdn-of-gitlab-server-where-git-repo-is'Context
StackExchange DevOps Q#4028, answer score: 3
Revisions (0)
No revisions yet.