Setup a GitLab Runner

First, get the "Registration Token" from your instance: https://${GITLAB_URL}/admin/runners.

Then run the registration:

docker run --rm -it -v "${CONFIG_DIR}:/etc/gitlab-runner" gitlab/gitlab-runner register

Then run the container:

docker run --rm -d --name gitlab-runner -v "${CONFIG_DIR}:/etc/gitlab-runner" -v "/var/run/docker.sock:/var/run/docker.sock" gitlab/gitlab-runner

You will likely need to alter the runner's configuration within the GitLab interface.

To get started, do the following:

  • Check "Run untagged jobs"
  • Uncheck "Lock to current projects"

Config

The config will look something like this. Multiple [[runners]] sections are allowed.

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "${RUNNER_NAME}"
  url = "https://${GITLAB_URL}"
  token = "${REGISTRATION_TOKEN}"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]