skip to Main Content

I’m attempting to register a Gitlab runner using Docker (running on Centos 7.6) using the following documentation:

https://docs.gitlab.com/runner/install/docker.html#docker-images
https://docs.gitlab.com/runner/register/index.html#docker

This documentation basically instructs me to (1) run the runner and then (2) register it:

  1. I run the runner:

docker run -d --name my-gitlab-runner --restart always
-v /srv/gitlab-runner/config:/etc/gitlab-runner
-v /var/run/docker.sock:/var/run/docker.sock
gitlab/gitlab-runner:latest

  1. I register the runner (which completes without issue):

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register

The registration documentation referred to by the 2nd URL mentions “In this section, you will launch an ephemeral gitlab-runner container to register the container that you created during install.”

My problem is that I don’t see where/how this registration process links the container that I created in step 1 with the Gitlab runner. The registration links the runner with an image but not an actual container instance. The registration isn’t run from within the container created in step 1. How does Gitlab know that the runner I have just registered corresponds to the container that I created in step 1 and not some other container.

I must be missing something obvious so any help is much appreciated.

Thanks.

3

Answers


  1. Instead of starting container at host machine (that one who has docker installed), you register your runner usual way:

    sudo gitlab-runner register
    

    But as executor you specify – docker

    Login or Signup to reply.
  2. Both containers (the temporary one and the actual gitlab-runner instance) share a volume together -v /srv/gitlab-runner/config:/etc/gitlab-runner in which the registration token is stored. The actual instance of the runner can then use that token from the generated config to authenticate with the gitlab instance.

    Login or Signup to reply.
  3. I use this command

    sudo docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search