1. Runner types and executors #
Choosing where jobs run.
Scope #
- Instance runner: available to every project (GitLab.com shared runners).
- Group runner: for a group's projects; project runner: dedicated to one project.
- Tags route a job to a specific runner (
tags: [gpu]); a runner may or may not accept untagged jobs.
Executors #
2. Installing and registering #
A runner in a container.
Installation #
docker volume create gitlab-runner-config
docker run -d --name gitlab-runner --restart always \
-v gitlab-runner-config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:v19.6.1
docker exec -it gitlab-runner gitlab-runner register --non-interactive \
--url https://gitlab.com --token "$RUNNER_TOKEN" \
--executor docker --docker-image python:3.12-slim --description poste-local- Since GitLab 16, you create the runner in the UI (Settings › CI/CD › Runners › New project runner), which provides a
glrt-…authentication token; the old registration token is removed. - Configuration lives in
/etc/gitlab-runner/config.toml:concurrent(simultaneous jobs), volumes, default image, cache. - A distributed cache (S3, GCS) shares the cache between several runners or ephemeral machines.
3. Runner security #
A runner runs arbitrary code.
Rules #
| Risk | Mitigation |
|---|---|
| Mounting /var/run/docker.sock gives control of the host | only for trusted runners; prefer Buildah or Kaniko (rootless) to build images |
| Privileged mode (Docker-in-Docker) | isolate on dedicated, ephemeral machines |
| Forks and external merge requests | no self-hosted runner on public projects without control; protected variables |
| Secrets left on the machine | ephemeral runners (autoscaler, Kubernetes), volume cleanup |
Best practice : Separate runners by trust level: a runner that deploys to production must only serve protected branches ("protected" option).
Commands to know #
Commands to know
gitlab-runner register: register a runnergitlab-runner list: configured runnersgitlab-runner verify: check the connectiondocker logs -f gitlab-runner: runner log
Sources #
Checked in November 2026: CI/CD platforms change every month, check versions and plans in the vendor's documentation.
