Skip to main content

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.