| config | ||
| .gitignore | ||
| compose.yml | ||
| env.example | ||
| README.md | ||
gitlab-runner on docker
Use this template to start your own gitlab-runner on docker.
Setup
-
Configure environment variables (optional):
cp env.example .env # Edit .env to set GITLAB_RUNNER_VERSION if needed -
Configure the runner: Either use the included
./config/config.toml.exampleand copy it to./config/config.tomlor create your own. By default the container should create a newconfig.tomlfile in the./configdirectory if it is not present. -
Register the runner (if using your own
config.tomlor the default creation): Start the container and attach a shell in the container and run thegitlab-runner register --url https://gitlab.example.com --token your-secret-tokencommand and follow the instructions. -
Start the runner:
docker compose up -d
If you use docker in docker, make sure to add
/var/run/docker.sock:/var/run/docker.sock in your ./config/config.toml, e.g.
# ...
[[runners]]
name = "runner on stefan-workstation"
url = "https://gitlab.example.com"
# ...
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.docker]
# ...
volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
# ...
[runners.feature_flags]
FF_NETWORK_PER_BUILD = true
Important: The FF_NETWORK_PER_BUILD = true feature flag is required when using
Docker 29+ or newer GitLab Runner versions to avoid the deprecated container linking
mechanism. This flag enables per-job Docker networks instead of using the deprecated
--link feature. For more information, see the
GitLab Runner Docker Executor documentation.
Configuration Files
compose.yml- Docker Compose configuration file (modern naming, noversionfield)env.example- Example environment variables file (copy to.envto customize)config/config.toml.example- Example GitLab Runner configuration