Runners

Concept introduction and purpose

GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline. It can be installed on your own infrastructure or used as a cloud service from GitLab. Runners are the agents that run the CI/CD jobs that come from GitLab. Executors determine the environment each job runs in. You can use GitLab Runner to run jobs over multiple machines and send the results to GitLab. To use GitLab Runner, you must choose an executor.

You can register the runner as shared group runner or specific to a project while installing it.

Register group runner

Most of the time it makes sense to create the runner on a level where many projects can use the same one. In this way, resources can be saved.
If individual runners have to be used for security or compliance reasons, this can also be done at project level.

You can find detailed instructions for different operating systems here: https://docs.gitlab.com/runner/register/

Deploy new runner using docker container

A new Gitlab Runner can be added relatively easily. This technology makes it possible to build, test and deploy code automatically, as it provides a compute container for automation in the Gitlab (GIT) environment. The easiest way is to install a Gitlab Runner on a Docker host. Docker-compose is very suitable for this, as the configuration is stored in a file.

Using docker-compose

This configuration can be used to create a new container. This does not yet have a connection to your Gitlab instance or to the cloud. The configuration is then carried out in the section below.

To create a container, you must create a docker-compose.yml file. There you can copy this configuration and customize it according to your preferences.

version: '3'
services:
  gitlab-runner:
    image: 'gitlab/gitlab-runner:latest'
    container_name: <yourcontainername>
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - <yourpersistantdatapath>:/etc/gitlab-runner
    restart: unless-stopped

You can then create the container in the same folder as the file ligt using the command "docker-compose up -d".

Registration procedure

To link the Gitlab Runner with your Gitlab instance and your account, the registration procedure must be carried out. To do this, you must run the registration on the console of your container.

docker exec <yourcontainername> /bin/bash -c register

When this command is executed, a dialog appears. You must follow the wizard to connect to your Gitlab.