Creating & Launching GitLab Runner Docker Image With Rancher

I needed a GitLab Runner for my GitLab server.  I did not launch GitLab using Docker/Rancher, because I wanted to be able to do some things with it which might have been difficult to accomplish with GitLab running inside a container.  I did attempt it but kept running into roadblocks.  I am currently running GitLab 8.13, having just updated yesterday.

Created a folder on my EFS to hold the config settings


This will get mounted into my docker container.

Create Files And Folders for Catalog

Created proper directory structure in my Rancher-Catalog/templates folder.



Contents of my Config.yml

name: GitLab Runner
 GitLab Docker Runner for GitLab CE
version: 1
category: Continuous Integration

Contents of My Docker-compose.yml

   io.rancher.container.pull_image: always
   io.rancher.scheduler.affinity:host_label: name=rancherpool-pvt ## This makes sure that my container only runs on private Rancher instances.
 image: gitlab/gitlab-runner:latest ## You could pull this image, store it in your own registry if you want.  Then pull it from there.
 privileged: true
 - /efs/data/gitlab-runner/config:/etc/gitlab-runner
 - /var/run/docker.sock:/var/run/docker.sock

Contents of my Rancher-compose.yml

 name: "GitLabRunner"
 version: "0"
 description: "GitLabRunner"
 uuid: "GitLabRunner-0"
 minumum_rancher_version: "v1.0"
 scale: 1

Pushed Files To My Rancher Catalog


After refreshing my catalog in Rancher, I now see my GitLab Runner.  I launched it.

Register My Runner with GitLab

You will need some information in order to register your new runner.  Once you register it, the config file is saved to the mounted volume and can be used to create multiple identical runners.

In GitLab click on Admin and Runners.  Make a note of your Registration Token.

Once I had the container running.  I launched a shell session using the Rancher GUI and I ran this command:

gitlab-runner register
This is what my session looked like:

gitlab-runner register
Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g.
Please enter the gitlab-ci token for this runner:
Please enter the gitlab-ci description for this runner:
[1227eaca85a8]: docker-runner
Please enter the gitlab-ci tags for this runner (comma separated):
Registering runner... succeeded                     runner=oRztgxRS
Please enter the executor: parallels, virtualbox, kubernetes, docker-ssh, shell,
ssh, docker+machine, docker-ssh+machine, docker:
Please enter the default Docker image (eg. ruby:2.1):
Runner registered successfully. Feel free to start it, but if it's running alrea
dy the config should be automatically reloaded!

Explanation Of The Items In Bold: = Path to your gitlab server.

mYreGistraTionTokEn = Your Registration Token from GitLab

docker-runner = description you choose for this Runner.  If it going to be a shell runner you might name is shell-runner.

docker = the tag for this runner.  Any CI instructions that are tagged with “docker” will use this runner to process.

docker = Type of runner. In this case its a docker type of runner

fstab/awscli = The docker image I want to run my builds. I chose this one because I wanted the AWS CLI to be available during my builds.

After the changes were made I now see a file on my mapped drive called config.toml

Contents of config.toml

concurrent = 1
check_interval = 0
 name = "docker-runner"
 url = ""
 token = "5351b527e85ea64e1da45da5234c3c"
 executor = "docker"
   tls_verify = false
   image = "fstab/aws-cli"
   privileged = false
   disable_cache = false
   volumes = ["/cache"]

I tested this with a simple tutorial I found here: . Note that if you follow this tutorial, you will need to add the tag to your CI instructions:

    - docker
Follow by Email

3 thoughts on “Creating & Launching GitLab Runner Docker Image With Rancher

    • cloudlady Post authorReply

      I would love for that to happen, but I don’t have a public repository. Do you know anyone who does? I would be happy to share.

  1. Mika Andrianarijaona Reply

    I know a public one we are currently using :
    Also I am interested to know if there is a way to simply set ‘privileged = true’ instead of ‘ privileged = false’ (we want to do some docker-in-docker builds directly in gitlab.

Leave a Reply

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