Continuous Integration Pipelines with GitLab using Docker

Watch out! This tutorial is over 6 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

This tutorial is very similar to the previous one, except this time we will create our GitLab Runner on Docker. As we won’t be repeating a lot of the material, please read the other tutorial first.

Rather than using XOA to create your GitLab Runner, you can also use a container via https://docker.comp.dkit.ie

There’s even an App Template for this purpose.

Go ahead and fire up a Container from this template, default settings (create a private network if you don’t already have one). Once up and running, connect to the web console using the appropriate icon and log on as root.

Setup is very similar to the last post, but with the following differences.

  • There is no need to install the gitlab-runner binary as it is already included.
  • The base layer is Ubuntu here, not Debian. Their nodejs package does not seem to include npm, so we will need to specify that.

Given the above, here are the commands to execute.

apt-get update && apt-get dist-upgrade
apt-get install sudo build-essential nodejs npm

You should then grant sudo nopasswd to user “gitlab-runner” in /etc/sudoers as before.

gitlab-runner ALL=(ALL) NOPASSWD: ALL

and now run the command to register the Runner:

gitlab-runner register

Very importantly, chose SHELL as the executor. We are inside the container, not outside, so the system thinks it is just a regular machine! Once complete, go back and check your project’s available Runners.

and test as before.

You will note that creating a Runner using Docker is much quicker and less resource intensive as using a Virtual Machine.