GitLab can be self-hosted quite easy. One way is, to run the server in a docker container, which will be described in this article. Our goal is to run a self-hosted GitLab server on a server with a public IP and domain name with GitLab-Runners for CI / CD.

To start with, we will update our server (in our case Debian 10) and install docker-compose:


Next, we will configure our docker setup. Our GitLab-Server should be located in /srv/gitlab (for example). Therefore we create this folder and add the file docker-compose.yml


After creating this file, we can startup the GitLab server. The initial start will take a few minutes since everything is set up and configured:


You can check the logs with the following command:


During startup, an HTTPS Certificate is generated via Let’s encrypt. When this is done you can open the corresponding domain in the browser and set up the initial password for the user “root”

Now it’s time to configure the runner!

In the admin section (https://<YOUR DOMAIN FOR THE GITLAB SERVER>/admin/runners) you can see the registration token for the runner.

Open the terminal and execute the following command in the folder /srv/gitlab:


The first “gitlab-runner” is the container name, which we set in our docker-compose.yml (just in case you chose another name)

In the runner registration process, you have to enter the domain (https://<YOUR DOMAIN FOR THE GITLAB SERVER>), the token from the Admin page, a description and optional tags.

When GitLab runner is able to connect to the GitLab instance, you will be asked to enter the executor. In our case, we’ll choose “docker” and “alpine:latest” as the default Docker image.

After this, you should see that our runner is connected to our GitLab Server in the Runner-Setting page (https://<YOUR DOMAIN FOR THE GITLAB SERVER>/admin/runners).

To make this runner available for all projects in the GitLab instance, you have to go to the runner settings and disable the option “Lock to current projects”.

Now you have your self-hosted GitLab instance with CI / CD capabilities!

Join the conversation


  1. Hi there,

    this tutorial was a godsend, I’m not sure why, but I struggeled with the docs and this was a breeze. Thanks a ton!

  2. This tutorial helped a lot, but didn’t quite get me to the finish-line. I’m trying to run GitLab behind a reverse-proxy (also a container, running on the same machine), and while I can access the GitLab WebUI, I can’t connect the runner to GitLab due to GitLab generating a self-signed SSL-certificate… Any insight here?

Leave a comment

Your email address will not be published. Required fields are marked *