{"id":3054,"date":"2025-05-12T08:51:51","date_gmt":"2025-05-12T08:51:51","guid":{"rendered":"https:\/\/jan.schnasse.org\/blog\/?p=3054"},"modified":"2026-09-28T11:37:10","modified_gmt":"2026-09-28T09:37:10","slug":"install-gitlab-runner-in-docker-rootless-for-dind","status":"publish","type":"post","link":"https:\/\/jan.schnasse.org\/blog\/2025\/05\/12\/install-gitlab-runner-in-docker-rootless-for-dind\/","title":{"rendered":"Install Gitlab Runner in Docker Rootless for dind"},"content":{"rendered":"<p>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.<\/p>\n<p>In my self administered environments I use a docker rootless setup most of the time.<\/p>\n<p>How to register a gitlab-runner from within a docker-rootless environment?<\/p>\n<p>1. Go to your group or project. Find the &#8222;runners&#8220; entry in the &#8222;Build&#8220; menu.<\/p>\n<p>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.<\/p>\n<p>3. SSH to your docker rootless host as &#8222;docker&#8220; user.<\/p>\n<p>4. Find your userid by typing <code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">id <\/code><\/p>\n<p>&#8211; Lets say it gives 1004<\/p>\n<p>5. Start a gitlab-runner container using a socket mount from your users directory <code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/run\/user\/1004<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">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<\/pre>\n<p>6. Register the runner<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">docker run --rm -t -i -v \/srv\/gitlab-runner\/config:\/etc\/gitlab-runner --name gitlab-runner gitlab\/gitlab-runner register<\/pre>\n<p>7. If you are on gitlab.com simply add\u00a0<code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">https:\/\/gitlab.com<\/code><\/p>\n<p>as runner location. It will find your runner by entering the token you have copied in Step 2. User <code>docker<\/code>as executer.<\/p>\n<p>8.\u00a0 Now the runner should be connected. You can make use of by configuring it at your\u00a0<code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">project\/settings\/ci<\/code>config.<\/p>\n<p>9. You can also add additional runner config under <code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">~\/.local\/share\/docker\/volumes\/gitlab-runner-config\/_data\/config.toml<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">  GNU nano 6.2                                                    \/home\/docker\/.local\/share\/docker\/volumes\/gitlab-runner-config\/_data\/config.toml\nconcurrent = 1\ncheck_interval = 0\nshutdown_timeout = 0\n\n[session_server]\n  session_timeout = 1800\n\n[[runners]]\n  name = \"my-runner\"\n  url = \"https:\/\/gitlab.com\/\"\n  id = 47413623\n  token = \"XXX-your-token-here-XXX\"\n  token_obtained_at = 2025-05-12T06:29:10Z\n  token_expires_at = 0001-01-01T00:00:00Z\n  executor = \"docker\"\n  [runners.cache]\n    MaxUploadedArchiveSize = 0\n    [runners.cache.s3]\n    [runners.cache.gcs]\n    [runners.cache.azure]\n  [runners.docker]\n    tls_verify = false\n    image = \"docker:latest\"\n    privileged = false\n    disable_entrypoint_overwrite = false\n    oom_kill_disable = false\n    disable_cache = false\n    volumes = [\"\/cache\",,\"\/run\/user\/$ID_OF_YOUR_DOCKER_USER\/docker.sock:\/var\/run\/docker.sock\"]\n    shm_size = 0\n    network_mtu = 0\n<\/pre>\n<p>10. Docker Compose<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">docker-compose.yml<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">services:\n  gitlab-runner:\n    image: gitlab\/gitlab-runner:latest\n    restart: always\n    container_name: gitlab-runner\n    volumes:\n      - gitlab-runner-config:\/etc\/gitlab-runner\n      - \/run\/user\/1004\/docker.sock:\/var\/run\/docker.sock\nvolumes:\n  gitlab-runner-config:<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-3054","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/3054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/comments?post=3054"}],"version-history":[{"count":1,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/3054\/revisions"}],"predecessor-version":[{"id":3632,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/3054\/revisions\/3632"}],"wp:attachment":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/media?parent=3054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/categories?post=3054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/tags?post=3054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}