I’m trying to get a basic setup of GitLab with one shared runner working from docker containers, but I keep getting this when I try to register:
ERROR: Registering runner... forbidden (check registration token) runner=Ds-3E59o
PANIC: Failed to register this runner. Perhaps you are having network problems
These are the steps I take (tested from fresh by removing /srv/gitlab
):
- Run GitLab:
# As per https://docs.gitlab.com/omnibus/docker/#pre-configure-docker-container.
sudo docker run --detach \
--hostname gitlab.example.com \
--env GITLAB_OMNIBUS_CONFIG="external_url 'http://gitlab.example.com/'; gitlab_rails['lfs_enabled'] = true;" \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
- Run the runner:
# As per: https://docs.gitlab.com/runner/install/docker.html#docker-image-installation.
docker run -d --name 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
-
Wait for gitlab to start, set root password, login as root, go to Configure GitLab -> Overview -> Runners, copy the access token.
-
Attempt to register the runner:
# As per: https://docs.gitlab.com/runner/register/index.html#one-line-registration-command.
docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--executor "docker" \
--docker-image alpine:latest \
--url "http://gitlab.example.com/" \
--registration-token "VMTMR8TysySosb6xuTLZ" \
--description "docker-runner" \
--tag-list "docker" \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected"
At this point, I get the error shown above.
I know it seem weird to run the runner and register it while it’s running but 1. the documentation has it this way and 2. I get the same result when registering first.
Am I doing something stupid?