Concepts
- Runner is an application that works with GitLab CI/CD to run jobs in a pipline.
- Runner can run multiple jobs and use multiple tokens with multiple servers.
- An executor determines the environment each job runs in.
- Jobs will be executed by executor in different platforms: Local, Docker, Docker with SSH, remote ssh server
- When you install GitLab Runner in a Docker container and choose the Docker executor to run your jobs, it’s sometimes referred to as a
“Docker-in-Docker”
configuration. - Specify the name of the runner or its tags in your
.gitlab-ci.yml
file. Then, when you commit to your repository, the pipeline runs, and the runner’s executor processes the commands.
Docker in Docker configuration
Run GitLab Runner in a container
- You could use system volume mounts to start the Runner container note: On macOS, use /Users/Shared instead of /srv .
1
2
3
4docker 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
- Then, you need to register this runner. By execute the following script, you will be asked to provide GitLab instance URL, token to register the runner, tags associated with the runner, runner exector (such as docker), default docker image and etc.
1
docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
- Finally, you need update the ci file. For a job, if you want to use the specific runner we just registered, you need add
tags
field for that job.
Config
- You could edit the
config.toml
file to config the runner. - Then use the following command to update the config.
1
docker restart gitlab-runner
Reference
https://docs.gitlab.com/runner