Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
In GitLab: project → Settings → CI/CD → Runners → New project runner, add the tags docker, linux, create it, copy the glrt-… token. On the server (GitLab Runner installed):
gitlab-runner register --non-interactive --url https://gitlab.com --token glrt-XXXXXXXXXXXXXXXXXXXX --executor docker --docker-image alpine:3.22 --description "build-01"
gitlab-runner verify
systemctl status gitlab-runner --no-pagerThen send jobs to it with tags: in .gitlab-ci.yml.
Step by step
- Create the runner in GitLab (since GitLab 16 the UI creates the runner and gives an authentication token
glrt-…; the old registration tokens are going away). Set the tags and "Run untagged jobs" there. - Register it on the server (the quick answer). The settings are written to the config file:
concurrent = 4
[[runners]]
name = "build-01"
url = "https://gitlab.com"
token = "glrt-XXXXXXXXXXXXXXXXXXXX"
executor = "docker"
[runners.docker]
image = "alpine:3.22"
privileged = false
volumes = ["/cache"]concurrent = how many jobs at the same time. Keep privileged = false.
- Send jobs to this runner with tags in the pipeline:
stages: [test, build]
test:
stage: test
image: python:3.13-slim
tags: [docker, linux]
script:
- pip install -r requirements.txt
- pytest -q
build-image:
stage: build
image: quay.io/buildah/stable
tags: [docker, linux]
variables:
STORAGE_DRIVER: vfs
BUILDAH_ISOLATION: chroot
script:
- buildah login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- buildah build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
- buildah push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCHThe image build uses Buildah with vfs storage and chroot isolation — no Docker socket and no privileged mode. Pin the Buildah image to the version tag you tested. (Google archived Kaniko in 2025; if you still use it, move to Buildah or a maintained fork.) If your runner's security settings block Buildah, give image builds their own, separate runner.
- Watch it work:
gitlab-runner list
journalctl -u gitlab-runner -f- Keep it safe: one runner per trust level (do not let public projects use the runner of your production deploys), protected runners for protected branches, no
privileged, no mounteddocker.sock, and update the runner regularly.
Check that it worked
In GitLab, Settings → CI/CD → Runners shows the runner with a green dot. Run a pipeline: the job log starts with Running with gitlab-runner … on build-01.
Common problems
| Problem | Cause | Fix |
|---|---|---|
| Job is stuck: "This job is stuck because you don't have any active runners that can run this job" | The job's tags do not match any runner, or untagged jobs are not allowed. | Make the job tags: match the runner's tags exactly. |
| Runner shows grey / never contacted | Service not running, or the server can not reach GitLab. | systemctl status gitlab-runner; test curl -I https://gitlab.com. |
ERROR: Verifying runner... is removed | The runner was deleted in GitLab, or the token is wrong. | Create a new runner, register again, remove the old block from config.toml. |
Cannot connect to the Docker daemon in the job | Docker is not running, or the job tries Docker-in-Docker. | Start Docker; build images with Buildah instead of Docker-in-Docker. |
| Jobs fill the disk | Old images and build cache. | Scheduled docker system prune with a time filter. |
| A job can read secrets of another project | Shared runner between projects of different trust. | Separate runners; protected variables and protected runners. |
Go further
- Command pages: gitlab-runner, docker, systemctl.
- Next how-tos: Create a CI pipeline in GitHub Actions, Free disk space used by Docker, Push an image to a private registry.
- Full guides: GitLab Runner, Buildah and Skopeo, Docker.
- At work: GitLab Runner in daily use, Runners in DevOps delivery.
1A job stays pending and says there is no active runner. What do you check first?
That the job's tags: match the runner's tags (and whether the runner may run untagged jobs).
2Why avoid privileged = true on a runner?
A privileged job can control the host — anyone who can change the pipeline gets root on the runner.