GitLab Runner Setup
Install Docker
Start the container
docker run -d --name gitlab-runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/gitlab-runner:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
Register it with a Project on GitLab
Project -> Settings -> CI/CD -> Runners -> Create Project Runner
The interface should present you with a command to run, this command should be executed from within the container that was started earlier.
docker exec -it gitlab-runner bash
# gitlab-runner register --url https://gitlab.com/ --token token
The runner should now be registered.
Running a Local Image
Our setup is only one runner and we wish to execute a just built container
without publishing it (this is probably not the best of ideas but it
should work in most cases). To prefer a local image add the red line to
the file in /etc/gitlab-runner/config.toml
:
```
concurrent = 1
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "..."
url = "https://gitlab.com/"
id = 1
token = "glrt-..."
token_obtained_at = 2025-08-11T12:24:41Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
<span style="color:red;">pull_policy = "if-not-present"</span>
tls_verify = false
image = "alpine:latest"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
network_mtu = 0
```
Also of interest here is the volumes
directive which will allow the container
to write things to the mapped volumes, very useful for caching.
Example configuration found on SO:
build_dir = "(Your build dir)"
[runners.docker]
volumes = ["/tmp/build-dir:/(build_dir):rw"]