Issue
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:
- 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
- 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.
Solution
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.
Answered By - pat