Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 46CI/CD · GitLab

How to run GitLab CI jobs on your own runner

Your pipelines need access to a private network, more power, or a specific tool — so the jobs should run on your server, not on shared runners. GitLab Runner is the agent that takes jobs from GitLab and runs them. This how-to registers a runner with the new token flow, sends the right jobs to it with tags, checks that it works, and fixes the classic "job stuck in pending".

  • 5 Lessen
  • 6 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

46.1

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-pager

Then send jobs to it with tags: in .gitlab-ci.yml.

46.2

Step by step

  1. 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.
  2. Register it on the server (the quick answer). The settings are written to the config file:
/etc/gitlab-runner/config.toml
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.

  1. Send jobs to this runner with tags in the pipeline:
.gitlab-ci.yml
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_BRANCH

The 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.

  1. Watch it work:
gitlab-runner list
journalctl -u gitlab-runner -f
  1. 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 mounted docker.sock, and update the runner regularly.

46.3

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.

46.4

Common problems

ProblemCauseFix
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 contactedService not running, or the server can not reach GitLab.systemctl status gitlab-runner; test curl -I https://gitlab.com.
ERROR: Verifying runner... is removedThe 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 jobDocker is not running, or the job tries Docker-in-Docker.Start Docker; build images with Buildah instead of Docker-in-Docker.
Jobs fill the diskOld images and build cache.Scheduled docker system prune with a time filter.
A job can read secrets of another projectShared runner between projects of different trust.Separate runners; protected variables and protected runners.

46.5

Go further

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.

Alle commando's in dit hoofdstuk