0

Context

While trying to self-host a GitLab server and docker runner locally, I'm experiencing some difficulties making the docker runner work. The error I get is:

Running with gitlab-runner 15.4.0 (43b2dc3d)
  on somerunner -kxe1YAs
Preparing the "docker" executor
00:05
Using Docker executor with image python:3.6 ...
Pulling docker image python:3.6 ...
Using docker image sha256:54260638d07c5e3ad24c6e21fc889abbc8486a27634c0892086ff71f3f44b104 for python:3.6 with digest python@sha256:f8652afaf88c25f0d22354d547d892591067aa4026a7fa9a6819df9f300af6fc ...
Preparing environment
00:00
Running on runner--kxe1yas-project-2-concurrent-0 via pcname...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/gitlab-instance-e541c583/lab_sponsor_example/.git/
fatal: unable to access 'http://127.0.0.1/gitlab-instance-e541c583/lab_sponsor_example.git/': Failed to connect to 127.0.0.1 port 80 after 0 ms: Connection refused
ERROR: Job failed: exit code 1

This answer suggests that the error occurs because the docker runner looks at 127.0.0.1 by default for the GitLab server, but can't find it there, because it is looking inside the docker container instead of inside the actual pc running the GitLab server.

The GitLab runner config is:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "trucolrunner"
  url = "http://127.0.0.1"
  id = 1
  token = "sometoken"
  token_obtained_at = 2022-10-12T17:37:57Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:20.10.16"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/certs/client", "/cache"]
    shm_size = 0
    extra_hosts = ["ci.mygitlab:127.0.0.1"]

The extra_hosts = ["ci.mygitlab:127.0.0.1"] line was added manually to see if I can make the docker runner find the GitLab server. That is done because this answer and this answer suggest that that helps the docker runner to find the GitLab server that exists outside the docker container. However, with or without that line, the error remains unchanged.

Assumption

I assume that the issue indeed is that the docker runner cannot find the GitLab server from within the docker. I also assume that

Run Gitlab under a domain name - it may be totally virtual, just make sure that all your VMs can resolve the domain name. may be the solution to get the docker runner to work locally.

Question

How can I run GitLab under a virtual domain name, whilst keeping the GitLab server independent of any actual domain names/registrations/dns servers?

a.t.
  • 2,002
  • 3
  • 26
  • 66

0 Answers0