Install Gitlab Runner in Docker Rootless for dind

Gitlab offers a well designed platform for open source projects. In the free version it is possible to use up to 400 min (?) runner time for CI-Jobs. It is also possible to connect self hosted gitlab-runners to power up you CI-Environment.

In my self administered environments I use a docker rootless setup most of the time.

How to register a gitlab-runner from within a docker-rootless environment?

1. Go to your group or project. Find the “runners” entry in the “Build” menu.

2. Add a new runner and copy the token to an editor or leave the page open for further reference (see step 7). Save everything.

3. SSH to your docker rootless host as “docker” user.

4. Find your userid by typing id

– Lets say it gives 1004

5. Start a gitlab-runner container using a socket mount from your users directory /run/user/1004

docker run -d --name gitlab-runner --restart always -v /run/user/1004/docker.sock:/var/run/docker.sock -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner:latest

6. Register the runner

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register

7. If you are on gitlab.com simply add https://gitlab.com

as runner location. It will find your runner by entering the token you have copied in Step 2. User dockeras executer.

8.  Now the runner should be connected. You can make use of by configuring it at your project/settings/ciconfig.

9. You can also add additional runner config under ~/.local/share/docker/volumes/gitlab-runner-config/_data/config.toml

  GNU nano 6.2                                                    /home/docker/.local/share/docker/volumes/gitlab-runner-config/_data/config.toml
concurrent = 1
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "my-runner"
  url = "https://gitlab.com/"
  id = 47413623
  token = "XXX-your-token-here-XXX"
  token_obtained_at = 2025-05-12T06:29:10Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "ruby:3.1"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
    network_mtu = 0

 

Leave a Reply