Reputation: 65083
I'm in the process of deploying a gitlab-runner to kubernetes on google-cloud-engine so can quickly scale runners / send the configuration off to other people so they can run their own runners. But first, I wanted to try to see if I could get the runner hooked up locally on my laptop.
Setup I have a project that on gitlab that is public, but I don't think it matters, as the goal here is just to be able to run docker-based tests on the gitlab runner. With docker, I've proved to myself that it's possible via: https://github.com/NullVoxPopuli/vsts-agent-with-aws-ecr (a project I did for work)
Here is what I have so far for the gitlab runner:
#/bin/bash
docker stop gitlab-runner && docker rm gitlab-runner
docker run -d --name gitlab-runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/local/gitlab-ci-runner/config:/etc/gitlab-runner \
-v "$(pwd)/config.toml":/etc/gitlab-runner/config.toml:ro \
gitlab/gitlab-runner:alpine
docker exec -it gitlab-runner gitlab-runner register \
-n \
--url https://gitlab.com/ci \
--tag-list "docker,docker-compose" \
--run-untagged \
--registration-token my-runner-token \
--executor docker \
--description "Docker Runner" \
--docker-image "docker:dind" \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
--docker-privileged
and here is my config.toml:
concurrent = 4
[[runners]]
name = "precognition-gitlab-runner"
url = "https://gitlab.example.com/ci"
token = "my-runner-token"
executor = "docker"
run_untagged = true
[runners.docker]
tls_verify = false
image = "alpine"
privileged = true
disable_cache = false
volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
[runners.cache]
Insecure = false
Now, when I run the script that run the gitlab-runner and then registers it, I do see it in gitlab in https://gitlab.com/project_name/settings/ci_cd
But, it says that the runner has not connected yet:
What's the correct way to configure this?
Here is my .gitlab-ci.yml for anyone curious: https://gitlab.com/precognition-llc/aeonvera-ui/blob/registration-rework/.gitlab-ci.yml
it just runs other scripts, which in-turn run docker-compose which then runs the tests.
Upvotes: 4
Views: 4320
Reputation: 434
I had the same problem as you before.
It seems that the docker container quit after he finished registering the runner.
And for some reason I got the "container already exists" on the follow up command even though the docker run -rm
flag was set. Maybe the tutorial has an error or we misuderstand some of the steps there.
The way I solved it was to remove the container first with
docker stop gitlab-runner
docker rm gitlab-runner
And then start the already registerd container with:
docker run -d --name gitlab-runner --restart always -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
I hope it helps.
Upvotes: 4