On this page
- What does GitLab Runner do and what does it need?
- How do you install GitLab Runner on Ubuntu and Debian?
- How do you install it on Rocky Linux and AlmaLinux?
- How do you create and register a runner?
- How do you tune config.toml?
- How do you point a pipeline at the runner?
- How do you keep the runner secure and tidy?
- What are the common runner problems?
- Questions
What does GitLab Runner do and what does it need?
GitLab Runner is the agent that executes CI/CD jobs for a GitLab instance, either the public service or your own server. It polls GitLab for work over HTTPS, so the runner host needs outbound access to the GitLab URL and no inbound ports at all.
Choose the executor before you install:
- Docker: every job runs in a new container from the image named in the job. Clean, repeatable and the usual choice.
- Shell: jobs run directly on the host as the
gitlab-runneruser. Simple, but tools and leftovers are shared between jobs.
For the Docker executor, install Docker Engine first as described in the Docker Engine tutorial. If you also want GitLab itself, the GitLab CE image deploys it on Ubuntu 24.04; run the runner on a second server so builds do not compete with GitLab for memory.
How do you install GitLab Runner on Ubuntu and Debian?
Use the repository script from GitLab, which adds the signed apt source, then install the package. On Debian, pin the GitLab source first, because Debian carries an older package of the same name.
sudo tee /etc/apt/preferences.d/pin-gitlab-runner.pref >/dev/null <<'EOF'
Explanation: Prefer the GitLab packaged runner
Package: gitlab-runner
Pin: origin packages.gitlab.com
Pin-Priority: 1001
EOF
curl -fsSL https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt install -y gitlab-runner
gitlab-runner --version
sudo gitlab-runner statusThe pin file is harmless on Ubuntu, so you can use the same steps on both. If you prefer to read a script before piping it into a shell, download it first with curl -o and inspect it.
How do you install it on Rocky Linux and AlmaLinux?
The RPM variant of the same script adds a dnf repository:
curl -fsSL https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
sudo dnf install -y gitlab-runner
gitlab-runner --version
systemctl status gitlab-runner --no-pagerThe package creates the gitlab-runner user and a systemd service that is enabled at once. Keep the runner minor version close to your GitLab version; GitLab supports runners of the same major and minor release, and mismatched pairs can miss features.
How do you create and register a runner?
Create the runner in GitLab first, then register the server with the token GitLab gives you. Current GitLab releases use runner authentication tokens (prefix glrt-); the older registration tokens are deprecated and disabled by default.
- For one project open Settings, CI/CD, Runners and choose New project runner. For a group or the whole instance use the matching admin or group page.
- Set the tags, whether untagged jobs may run, and a timeout. These settings live in GitLab, not on the server.
- Copy the token shown after you create it.
sudo gitlab-runner register --non-interactive \
--url https://gitlab.example.net \
--token glrt-REPLACE_ME \
--executor docker \
--docker-image alpine:3.20 \
--description vps-docker-01
sudo gitlab-runner verify
sudo gitlab-runner listverify confirms that the token is valid and the runner can reach GitLab; the runner then shows a green dot on the runners page.
How do you tune config.toml?
Registration writes /etc/gitlab-runner/config.toml, and the runner reloads it on change without a restart. The settings that matter most:
concurrent = 2
check_interval = 0
[[runners]]
name = "vps-docker-01"
url = "https://gitlab.example.net"
token = "glrt-REPLACE_ME"
executor = "docker"
[runners.docker]
image = "alpine:3.20"
privileged = false
volumes = ["/cache"]
pull_policy = ["if-not-present"]
shm_size = 0- concurrent: the number of jobs that may run at the same time across all runners in the file. Start at the vCPU count and lower it if jobs run out of memory.
- pull_policy:
if-not-presentreuses cached images and saves transfer. - privileged: leave it false unless you need Docker in Docker; privileged containers can take over the host.
For container builds without privileges, tools such as Buildah in rootless mode avoid the need for Docker in Docker.
How do you point a pipeline at the runner?
Match the tags you gave the runner in the job definition. A short .gitlab-ci.yml:
stages: [test, build]
test:
stage: test
image: node:22
tags: [vps]
cache:
key: npm
paths: [.npm/]
script:
- npm ci --cache .npm
- npm test
build:
stage: build
image: node:22
tags: [vps]
script:
- npm run build
artifacts:
paths: [dist/]
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCHPush the file and watch the job log in GitLab. The first run pulls images, later runs reuse them. If you also use other CI systems, compare the setup with the GitHub Actions runner and Woodpecker CI guides.
How do you keep the runner secure and tidy?
Treat the runner host as a machine that executes other people's code, which is what it is. Keep it separate from production data, register it only for projects you trust, and use protected runners for jobs that deploy with production secrets (a protected runner only takes jobs from protected branches and tags).
Docker images and volumes from old jobs pile up quickly. The package ships a cleanup script you can run from a weekly timer or cron entry:
sudo /usr/share/gitlab-runner/clear-docker-cache
docker system dfApply updates with sudo apt upgrade gitlab-runner or sudo dnf upgrade gitlab-runner; running jobs finish before the service restarts. Watch CPU and disk with usage monitoring; the CI runners page explains how plans match build volume.
What are the common runner problems?
- Jobs stay pending: the job tags do not match any runner, or the runner does not accept untagged jobs. Compare tags on both sides.
- 403 or token errors: the runner was deleted in GitLab or the token was reset; register again.
- Cannot connect to the Docker daemon: Docker is not running; check
systemctl status docker. - No space left on device: run the cleanup script and prune build caches.
- Certificate errors with a self-hosted GitLab: give GitLab a valid certificate, for example from Certbot, instead of turning off verification.
The service log is in journalctl -u gitlab-runner -f.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about GitLab Runner
Is one runner enough for many projects?
Yes. Create a group or instance runner instead of a project runner, or register several runner entries in the same config.toml.
Should GitLab and the runner share a server?
It works for small setups, but jobs then compete with GitLab for CPU and memory. A separate runner server keeps the web interface responsive.
How do I remove a runner?
Run sudo gitlab-runner unregister --name vps-docker-01 on the server and delete it on the runners page in GitLab.
Do I need to open ports for the runner?
No. The runner connects out to GitLab. Keep inbound traffic limited to SSH.
Which executor should I use for Docker builds?
The Docker executor with a rootless builder is the safer default. Mounting the host Docker socket or running privileged containers gives jobs control over the host.