我正在运行带有gitlab
的容器。
我也尝试通过本文设置码头gitlab runner
。
首先,我尝试通过以下方式运行 gitlab 运行器:
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
...
我也通过这篇文章尝试了注册运行器:
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