无法配置/注册Docker化的GitLab Runner。

9

我有一个正在运行的容器,里面装有gitlab

同时我尝试按照这篇文章的步骤来配置基于docker的gitlab runner

首先,我尝试通过以下命令来运行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

日志显示:

...
Listen address not defined, session server disabled  builds=0
ERROR: Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory  builds=0
ERROR: Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory  builds=0
...

我也尝试按照这篇文章的指引注册runner:

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register

第五步完成后:

Please enter the gitlab-ci tags for this runner (comma separated):
 my-tag,another-tag

我遇到了错误:

ERROR: Registering runner... failed                 runner=KuwydETA status=couldn't execute POST against http://localhost/api/v4/runners: Post http://localhost/api/v4/runners: dial tcp 127.0.0.1:80: getsockopt: connection refused
PANIC: Failed to register this runner. Perhaps you are having network problems
1个回答

3
/srv/gitlab-runner/config 目录中,您需要插入 config.toml 文件。
您可以在以下位置找到注册令牌:https://{your_gitlab_host}/project_namespace/project_name/runners。使用以下内容创建临时配置文件作为模板:
$ cat > /tmp/test-config.template.toml << EOF
[[runners]]
[runners.docker]
[[runners.docker.services]]
name = "mysql:latest"
[[runners.docker.services]]
name = "redis:latest"
EOF

您现在可以使用刚创建的配置文件注册Runner:

gitlab-runner register \
  --non-interactive \
  --url "https://gitlab.com" \
  --registration-token "$REGISTRATION_TOKEN" \
  --template-config /tmp/test-config.template.toml \
  --description "gitlab-ce-ruby-2.7" \
  --executor "docker" \
  --docker-image ruby:2.7

来源: https://docs.gitlab.com/runner/examples/gitlab.html

https://docs.gitlab.com/runner/configuration/advanced-configuration.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接