Gitlab Runner Docker Compose Feature Image
%author% via %publisher%
Home / Creating a dockerized Gitlab Runner with Docker Compose
CI/CD

Creating a dockerized Gitlab Runner with Docker Compose

Quick post to show my configuration. I gave up using docker run commands for Gitlab Runners. All docker-compose configuration is checked into git and it is a much more sustainable setup.

Add the following service to your Gitlab’s docker-compose.yml. Note that the container must be linked to your Gitlab container.

Docker Compose File

runner:
    restart: unless-stopped
    image: gitlab/gitlab-runner:alpine
    container_name: gr
    links:
      - gitlab
    volumes:
      - /home/daniel/docker-data/gitlab-ci-data:/etc/gitlab-runner:Z
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - CI_SERVER_URL=http://gitlab/
      - REGISTRATION_TOKEN=yourtoken

Advertisement Begins

Advertisement End


Run docker-compose up -d runner and then register the runner manually using docker exec shown below. The host and token are prefilled, most things you can skip. WHen it asks for base image I typed alpine:latest

docker exec -it gr /bin/bash
bash-4.4# gitlab-runner register

In all likelihood you have to change your runner’s config.toml file in the containers gitlab-ci-data directory (see volumes section). I had to enable privileged mode and add "/var/run/docker.sock:/var/run/docker.sock" to the array of volumes below.

[[runners]]
  name = "entity-controller"
  url = "http://gitlab/"
  token = "your_yoken"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "docker"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.custom]
    run_exec = ""

MY MISSION

This blog started nearly 10 years ago to help me document my technical adventures in home automation and various side projects. Since then, my audience has grown significantly thanks to readers like you.

While blog content can be incredibly valuable to visitors, it’s difficult for bloggers to capture any of that value – and we still have to work for a living too. There are many ways to support my efforts should you choose to do so:

Consider joining my newsletter or shouting a coffee to help with research, drafting, crafting and publishing of new content or the costs of web hosting.

It would mean the world if gave my Android App a go or left a 5-star review on Google Play. You may also participate in feature voting to shape the apps future.

Alternatively, leave the gift of feedback, visit my Etsy Store or share a post you liked with someone who may be interested. All helps spread the word.

BTC network: 32jWFfkMQQ6o4dJMpiWVdZzSwjRsSUMCk6

Once done, save and restart the container with docker-compose restart runner.

Continue your adventure here

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

DON’T MISS OUT!
Subscribe To Newsletter
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Give it a try, you can unsubscribe anytime.
close-link