Skip to content

How to specify `extra_hosts` when uploading artifacts using Docker executor

First of all, I hosted an GitLab CE on my machine (1M bandwidth), an registered a runner to it (Docker image & as a Docker executor). They are in the same intranet, but GitLab CE is internet accessible.

My artifacts is over 15MB, so I noticed it went through internet instead of intranet. I added extra_hosts to the runner's docker-compose.yaml and in the runner's config I also added these:

concurrent = 1
check_interval = 0


[[runners]]
  name = "runner"
  url = "https://[my-gitlab-ce-domain]/"
  token = "[token]"
  executor = "docker"
  [runners.docker]
    extra_hosts = ["[my-gitlab-ce-domain]:[internal IP]"] # this line
    tls_verify = false
    image = "alpine:latest"
    privileged = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]

But it's still slow. After hours of debugging & searching, finally I found this doc:

The Docker executor divides the build into multiple steps:

Prepare: Create and start the services. Pre-build: Clone, restore cache and download artifacts from previous stages. This is run on a special Docker Image. Build: User build. This is run on the user-provided docker image. Post-build: Create cache, upload artifacts to GitLab. This is run on a special Docker Image.

Can I give extra_hosts to this special Docker Image? Or do I have other ways to achieve this? All I want is let runner communicate with GitLab through intranet.

Thanks!