Registering GITLAB-Runners

Vineet Kumar
2 min readJul 30, 2021

Registering a Runner is the process that binds the Runner with a GitLab instance.

Before registering a Runner, you need to first:

  • Install it on a (bare metal server or on docker container ) server separate than where GitLab is installed on
  • Obtain a token for a shared or specific Runner via GitLab’s interface (Gitlab UI -> Project or group -> settings -> CI/CD -> Runners -> copy url and token also)
  • First Method : To register a Runner (Bare Metal Server ) under GNU/Linux:
1. #sudo gitlab-runner register
After run this command enter below information
2. Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com ) https://gitlab.com3. Please enter the gitlab-ci token for this runner
xxx
4. Please enter the gitlab-ci description for this runner [hostname] my-runner5. Please enter the gitlab-ci tags for this runner (comma separated): my-tag,another-tag6. Please enter the executor (Choose shell): ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
shell
7. Check on Gitlab GUI under : Gitlab UI -> Project or group -> settings -> CI/CD -> Runners
IF choose docker executor then use alpine:latest image.

Second Method : To register a Runner (Docker Container) under GNU/Linux:

  1. Install Docker and create volume for gitlab runner
    docker volume create gitlab-runner-config
  2. Run Register Command:
    docker run -d --name gitlab-runner --restart always -v /var/run/docker.sock:/var/run/docker.sock -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner:latest
    If you change the configuration in config.toml, you might need to restart the runner to apply the change. Make sure to restart the whole container instead of using gitlab-runner restart:
    docker restart gitlab-runner

One line Registration command with docker excecutor:
docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register --non-interactive --executor “docker” --docker-image alpine:latest --url “https://mygiturl.com/" --tls-ca-file “/etc/gitlab-runner/certs/ca.crt -n” --registration-token “XXXXXXX” --description “docker-runner-MYFIRST-RUNNER” --tag-list “docker” --run-untagged=”true” --locked=”false” --access-level=”not_protected” --docker-privileged

2. If want to add memory to docker executor then embedded the following lines into above command
--docker-memory “24g” --docker-memory-swap “4g” --docker-memory-reservation “16g”

3. Enjoy

--

--