Introduction

GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline.

Prerequisites

  • Your GitLab repository supports CI/CD
    • You can enable the feature ON via following steps Settings → General → Visibility, project features, permissions → CI/CD
  • Server that supports docker (supported platforms)

Instructions

This section describes how to install and configure GitLab runner using docker on some server.

  1. Deploy virtual server in Portal

    Skip this step if you already have a server. 

    If you need new server, you can deploy one via TDS portal - Orchestration - Servers#Howtodeploynewserver

  2. Install Docker engine on server – choose one of the following options
    • Option A - using "convenience script" from official instructions – recommended only for development and testing purposes

      curl -fsSL https://get.docker.com -o get-docker.sh
      sudo sh get-docker.sh
      sudo systemctl start docker
    • Option B - specific approach for each relevant OS - basically setting up repository and installing Docker Engine - all supported OS instructions can be found at https://docs.docker.com/engine/install
      • CentOS - official instructions

        sudo yum install -y yum-utils
        sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
        sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
      • Fedora - official instructions

        sudo dnf -y install dnf-plugins-core
        sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
        sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
      • Ubuntu - official instructions

        sudo apt-get update
        sudo apt-get install ca-certificates curl gnupg lsb-release -y
        sudo mkdir -m 0755 -p /etc/apt/keyrings
        curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
        echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  3. Add your user to docker group to be able to run docker commands (more about security in article)

    sudo usermod -aG docker $USER
  4. Start docker container with latest version of gitlab runner (official instructions)

    docker run -d --name gitlab-runner --restart always -v /srv/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
  5. Configure GitLab runner to connect to your repository
    1. Go to desired GitLab repository → Settings → CI/CD → Runners
    2. Go to "Set up a specific runner for a project" section
      • Copy the "URL" and "registration token", you will need it in next steps
    3. Execute following command on the server with running docker container

      docker exec -it gitlab-runner gitlab-runner register --docker-privileged
    4. You will be prompted to fill-in following parameters:
      • URL from step 5.b.
      • Token from step 5.b.
      • Description
      • Tags for the runner (can leave this blank for the moment).
      • Specify docker executor
      • Specify a default Docker image (e.g. alpine:latest)
  • No labels