我正在运行带有
gitlab
的容器。
我还尝试通过
this文章设置dockerized
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
...
我还尝试通过this文章注册跑步者:
docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
5步后:
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
在
/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
您现在可以使用刚刚创建的配置文件注册运行器:
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