- 使用 System Volumn 掛載 Runner Container,執行 Gitlab Runner。
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
- 建立一個新的 Group runner。
👉 新增 Group runner 標籤
👉 獲取 token
更詳細的步驟可以參考這篇文章。
- 註冊 Runner
別忘了將 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"
- 編輯
/srv/gitlab-runner/config/config.toml
修改以下配置:
concurrent
:可選privileged
volumes
:docker 內部的 dockernetwork_mode
:可選
/srv/gitlab-runner/config/config.toml
concurrent = 4 # 更改
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "docker-runner"
url = "https://gitlab.com/"
id = 28470179
token = "glrt-vTJPYBaajfypaShJH2Ge"
token_obtained_at = 2023-10-14T12:45:43Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.docker]
tls_verify = false
image = "docker:stable-dind"
privileged = true # 更改
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
#volumes = ["/cache"] # 更改
volumes = ["/cache", "/var/run/docker.sock:/run/docker.sock"]
shm_size = 0
network_mode = "host" # 新增
- 重新啟動 Runner
docker restart gitlab-runner