📔 How to Setup Gitlab Runner in Container
1. Use local system volume mounts to start the runner container.
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
2. Create a group runner with a runner authentication token.
👉 _Add group runner tag_
👉 _Get authentication token_
3. Register a runner
Don't forget to change the authentication token.
RUNNER_TOKEN="glrt-vTJPYBaajfypaShJH2xx"
docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--token "$RUNNER_TOKEN" \
--executor "docker" \
--docker-image docker:stable-dind \
--description "docker-runner"
4. Edit /srv/gitlab-runner/config/config.toml
Modify the following configurations:
concurrent
: optionalprivileged
volumes
: docker in dockernetwork_mode
: optional
6. Restart Runner
docker restart gitlab-runner