$ run as a normal user# run as root (or with sudo)
Know it before you install
The runner asks GitLab for jobs (it connects out to GitLab, so no inbound port is needed). For each job it uses an executor: docker (each job in a fresh container — the most used), shell (on the host), kubernetes (each job in a Pod) and others.
| Item | Value |
|---|---|
| Package | gitlab-runner (from packages.gitlab.com) |
| Service | gitlab-runner.service, runs as user gitlab-runner |
| Config | /etc/gitlab-runner/config.toml |
| Logs | journalctl -u gitlab-runner |
| Network | outbound HTTPS (443) to your GitLab; no inbound port |
| Docker executor needs | Docker Engine on the same machine |
Install on RHEL, Rocky, Alma and Fedora
The GitLab script adds the repository; then install the package:
curl -fsSL https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh -o /tmp/runner-repo.sh
less /tmp/runner-repo.sh
bash /tmp/runner-repo.sh
dnf -y install gitlab-runner
gitlab-runner --versionInstall on Ubuntu and Debian
curl -fsSL https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh -o /tmp/runner-repo.sh
bash /tmp/runner-repo.sh
apt-get install -y gitlab-runner
systemctl status gitlab-runner --no-pagerFor the Docker executor, install Docker Engine too (see the Docker guide). The runner talks to Docker through the socket.
Register the runner
In GitLab, open your project (or group): Settings → CI/CD → Runners → New project runner. Add tags (for example docker, linux), choose if it may run untagged jobs, and click Create runner. GitLab shows a runner authentication token that starts with glrt-. Use it on the server:
gitlab-runner register --non-interactive --url https://gitlab.com --token glrt-XXXXXXXXXXXXXXXXXXXX --executor docker --docker-image alpine:3.22 --description "build-01"
Runner registered successfully.
gitlab-runner verify
gitlab-runner listNote
The token is shown only once and works like a password. The old way with a registration token and --registration-token is deprecated; use the runner token from the UI or API.
First configuration: config.toml
After registering, tune the file. The most important settings:
concurrent = 4
check_interval = 3
[[runners]]
name = "build-01"
url = "https://gitlab.com"
token = "glrt-XXXXXXXXXXXXXXXXXXXX"
executor = "docker"
[runners.docker]
image = "alpine:3.22"
privileged = false
pull_policy = ["if-not-present"]
volumes = ["/cache"]
shm_size = 0
memory = "4g"
cpus = "2"
allowed_images = ["registry.example.com/*", "docker.io/library/*", "alpine:*"]| Setting | Why |
|---|---|
concurrent | How many jobs run at the same time on this machine (about 1 per 2 CPU). |
privileged = false | Jobs can not get root on the host. Turn on only for Docker-in-Docker runners you trust. |
pull_policy if-not-present | Faster jobs; use always when images can change under the same tag. |
memory, cpus | One job can not take the whole machine. |
allowed_images | Jobs may use only images from places you trust. |
The runner reads the file again by itself after a change; check with journalctl -u gitlab-runner -f.
Watch out
The shell executor runs jobs directly on the host as the gitlab-runner user. If that user is in the docker group, every job is root on the host. Use the Docker or Kubernetes executor for untrusted code and merge requests.
Your first pipeline
Put .gitlab-ci.yml in the root of the repository:
stages: [test, build, scan]
default:
tags: [docker]
test:
stage: test
image: python:3.12-slim
script:
- pip install -r requirements.txt
- python -m pytest -q
build:
stage: build
image: quay.io/buildah/stable
script:
- buildah bud -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
- buildah push --creds "$CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD" "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
scan:
stage: scan
image:
name: aquasec/trivy:latest
entrypoint: [""]
script:
- trivy fs --exit-code 1 --severity HIGH,CRITICAL .Push it, then watch the job in Build → Pipelines. The job log shows Running with gitlab-runner … on build-01.
Daily commands on the runner machine:
gitlab-runner status
gitlab-runner verify
journalctl -u gitlab-runner -f
gitlab-runner unregister --name build-01
docker system df
docker system prune -af --filter "until=72h"Real uses at work:
- Fast builds close to your network: private registries, databases for tests, on-prem deploy targets.
- Protected runners only for protected branches — they hold the deploy credentials for production.
- Special runners: GPU, ARM, Windows, macOS, big memory.
Make it safe
Security checklist:
- Docker executor with
privileged = false; build images with Buildah or Kaniko instead of Docker-in-Docker. - Separate runners: one for merge requests (no secrets), protected ones for deploys.
- The runner token is a password: keep
config.tomlat600, rotate the token if it leaks. - Use masked and protected CI/CD variables for secrets; prefer OIDC (
id_tokens) to get cloud access without stored keys. - Limit images (
allowed_images), CPU and memory. - Clean old images and volumes (cron with
docker system prune); update the runner every month.
Update and remove
dnf -y upgrade gitlab-runner
apt-get install --only-upgrade -y gitlab-runner
gitlab-runner unregister --all-runners
dnf -y remove gitlab-runner
apt-get purge -y gitlab-runnerDelete the runner also in GitLab (Settings → CI/CD → Runners), so its token stops working.
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
| Job pending: "This job is stuck because you don't have any active runners that can run this job" | No online runner with the job's tags. | Check the tags in the job and on the runner; allow untagged jobs; gitlab-runner verify. |
Cannot connect to the Docker daemon at unix:///var/run/docker.sock | Docker is not running, or the runner has no access. | systemctl start docker; for the shell executor add gitlab-runner to the docker group (root risk). |
x509: certificate signed by unknown authority | Self-hosted GitLab with a company CA. | Put the CA in /etc/gitlab-runner/certs/gitlab.example.com.crt or use --tls-ca-file. |
| Runner shows "never contacted" or offline | Token wrong, no outbound HTTPS, or service stopped. | gitlab-runner verify; curl -I https://gitlab.com; systemctl status gitlab-runner. |
no space left on device in jobs | Old images, volumes and cache. | docker system prune -af; a cleanup cron; bigger disk. |
ERROR: Job failed: execution took longer than 1h | Job timeout. | Make the job faster, or raise the timeout in the project/runner settings. |
| Jobs on Docker-in-Docker fail | privileged is off (as it should be). | Use Buildah or Kaniko to build images. |
Next steps
- Quick how-to: Run GitLab CI jobs on your own runner.
- Command page: gitlab-runner.
- GitLab Runner at work: Run GitLab CI jobs, Pipelines in companies.
- The same pipeline idea on GitHub: Lab: build a CI pipeline.
- What the jobs need: Install and set up Docker Engine, Install and set up Git.
1Does the runner need an open inbound port?
No. It connects out to GitLab over HTTPS and asks for jobs.
2Why is privileged = true dangerous on a shared runner?
A job can then get root on the host and read other jobs' data and secrets.