GitLab Tutorials: Understanding runner config.toml & Example of config.toml

The config.toml file is what configures a runner. You wouldn’t have one unless you’re running your own gitlab-runners, in which case it would be in /etc/gitlab/config.toml on the host running the runner.

You can change the behavior of GitLab Runner and of individual registered runners.

To do this, you modify a file called config.toml, which uses the TOML format.

GitLab Runner does not require a restart when you change most options. This includes parameters in the [[runners]] section and most parameters in the global section, except for listen_address. If a runner was already registered, you don’t need to register it again.

GitLab Runner checks for configuration modifications every 3 seconds and reloads if necessary. GitLab Runner also reloads the configuration in response to the SIGHUP signal.

You can find the config.toml file in:

  • /etc/gitlab-runner/ on *nix systems when GitLab Runner is executed as root (this is also the path for service configuration)
  • ~/.gitlab-runner/ on *nix systems when GitLab Runner is executed as non-root
  • ./ on other systems

The executors

The following executors are available.

ExecutorRequired configurationWhere jobs run
shell Local shell. The default executor.
docker[runners.docker] and Docker EngineA Docker container.
docker-windows[runners.docker] and Docker EngineA Windows Docker container.
docker-ssh[runners.docker][runners.ssh], and Docker EngineA Docker container, but connect with SSH. The Docker container runs on the local machine. This setting changes how the commands are run inside that container. If you want to run Docker commands on an external machine, change the host parameter in the runners.docker section.
ssh[runners.ssh]SSH, remotely.
parallels[runners.parallels] and [runners.ssh]Parallels VM, but connect with SSH.
virtualbox[runners.virtualbox] and [runners.ssh]VirtualBox VM, but connect with SSH.
docker+machine[runners.docker] and [runners.machine]Like docker, but use auto-scaled Docker machines.
docker-ssh+machine[runners.docker] and [runners.machine]Like docker-ssh, but use auto-scaled Docker machines.
kubernetes[runners.kubernetes]Kubernetes pods.

The shells

The available shells can run on different platforms.

ShellDescription
bashGenerate Bash (Bourne-shell) script. All commands executed in Bash context. Default for all Unix systems.
shGenerate Sh (Bourne-shell) script. All commands executed in Sh context. The fallback for bash for all Unix systems.
powershellGenerate PowerShell script. All commands are executed in PowerShell Desktop context. In GitLab Runner 12.0-13.12, this is the default for Windows.
pwshGenerate PowerShell script. All commands are executed in PowerShell Core context. In GitLab Runner 14.0 and later, this is the default for Windows.

Example


$ more /etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800


[[runners]]
  name = "rajeshkumar"
  url = "http://43.205.228.212/"
  id = 3
  token = "AKrp1HueGK1DxaHxjNmD"
  token_obtained_at = 2022-09-06T06:40:14Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

[[runners]]
  name = "raju123"
  url = "http://43.205.228.212/"
  id = 16
  token = "aZ9zvKntG8-PKsm8s1HN"
  token_obtained_at = 2022-09-06T07:13:53Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

[[runners]]
  name = "gitlab-test"
  url = "https://gitlab.com/"
  id = 17373720
  token = "sJp-fyfCvj-K1M-yysfj"
  token_obtained_at = 2022-09-06T09:09:09Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

[[runners]]
  name = "docker"
  url = "https://gitlab.com/"
  id = 17388862
  token = "RDoZpsR8XzyuipDHzYsz"
  token_obtained_at = 2022-09-07T04:31:53Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "alpine"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

[[runners]]
  name = "group"
  url = "https://gitlab.com/"
  id = 17389806
  token = "ES9VZQ4eZx_yfEyxVeqm"
  token_obtained_at = 2022-09-07T05:09:40Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

[[runners]]
  name = "linux-runner"
  url = "https://gitlab.com/"
  id = 17390444
  token = "UHdwAw3MXnyf-C1NgwMR"
  token_obtained_at = 2022-09-07T05:49:15Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

[[runners]]
  name = "docker-runner"
  url = "https://gitlab.com/"
  id = 17390576
  token = "_nHBeXQVrwj8V-xxq899"
  token_obtained_at = 2022-09-07T05:57:22Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "alpine"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

Reference

  • https://docs.gitlab.com/runner/configuration/advanced-configuration.html
Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Ammar
Ammar
7 months ago

Thank you very much for sharing this.
I have a problem in my Gitlab pipeline. I am using windows (docker installed) and I select windows-docker as a executor. I am getting this error (although I already have cache folder inside the c drive):
Preparing the “docker-windows” executor
ERROR: Failed to remove network for build
ERROR: Job failed: invalid volume specification: “c:\\cache”

1
0
Would love your thoughts, please comment.x
()
x