基于的dockerfile链接
https://www.jianshu.com/p/ad1230e39b1a
version: '3'
services:
gitlab-runner-vue:
image: gitlab-runner-vue:v1
container_name: gitlab-runner-vue
ports:
- "6606:6606"
volumes:
- /home/cert_nginx:/cert
- /home/web:/home/web
restart: always
这里附带一个sh脚本
# 这条指令进行注册
docker exec -it gitlab-runner-vue gitlab-ci-multi-runner register --tls-ca-file=/etc/gitlab-runner/certs/2423367_www.micking.top_public.crt
# 注册完成后,一定要激活gitlab-runner,否则gitlab-ci/cd在执行job时,会找不到活动状态的gitlab-runner
# 每次重启容器后,也要记得使用这句命令激活gitlab-runner
docker exec -it gitlab-runner-vue gitlab-ci-multi-runner restart
注意:做完以上操作还有最终要的一步,就是进入容器,将gitlab-runner的权限提升到root,否则gitlab-runner无权限操作自身所在目录以外的目录的增删改查操作
# 进入容器
docker exec -it gitlab-runner-vue bash
---start-----这一段已经不需要了,我在dockerfile脚本终于找到通过指令修改的方法了-----
# 修改gitlab-runner权限的方式如下,编辑该文件,找到gitlab-runner
vim /etc/passwd
# 然后修改成类似下面这样的root权限
gitlab-runner:x:0:0:Gitlab Runner:/home/gitlab-runner:/bin/bash
---end-----这一段已经不需要了,我在dockerfile脚本终于找到通过指令修改的方法了-----
由于我的gitlab是开启了https协议的,所以gitlab-runner也需要把对应的https的cert证书复制到容器中,否则在注册gitlab-runer到gitlab对应的项目上时,会报错
报错内容如下
ERROR: Registering runner... failed runner=RfQa2UnC status=couldn't execute POST against https://www.micking.top:7193/api/v4/runners: Post https://www.micking.top:7193/api/v4/runners: x509: certificate signed by unknown authority
PANIC: Failed to register this runner. Perhaps you are having network problems
报错意思是:不信任这个https协议
百度到了解决方案:
(1)gitlab-runner register 注册报错
原文链接:https://blog.csdn.net/zuopiezia/article/details/88711750
ERROR: Registering runner... failed runner=yeN77YKp status=couldn't execute POST against https://gitlab.xxx.com/api/v4/runners: Post https://gitlab.xxx.com/api/v4/runners: x509: certificate signed by unknown authority (possibly because of "x509: invalid signature: parent certificate cannot sign this kind of certificate" while trying to verify candidate authority certificate "gitlab.xxx.com")
PANIC: Failed to register this runner. Perhaps you are having network problems
这个报错是在 gitlab 有http 改成https时 才出现的,与ca 证书有关。
需要gitlabserver 端 的证书 cp 到gitlab-runner 上,
再进行注册
[root@test-gitlab-runner ~]# gitlab-runner register -n
--tls-ca-file=/root/key/server.crt
--url=https://gitlab.sxw.com/
--registration-token=yeN77YKpPHVPgsWkJMhj
--name=test1
--run-untagged=true
--locked=true
--executor=shell
Runtime platform arch=amd64 os=linux pid=11003 revision=4745a6f3 version=11.8.0
Running in system-mode.
Registering runner... succeeded runner=yeN77YKp
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
[root@test-gitlab-runner ~]#
这次注册成功了_ _ _ !
(2)
原文链接:https://blog.csdn.net/londa/article/details/94144845
如果跟我一样,无论怎么设置gitlab-runner,它都一直卡住 pending 状态,请执行如下语句
原文链接: https://blog.csdn.net/qq_35721399/article/details/82778660
注意:下面语句中的 【gitlab-runner-xxx】是你的gitlab-runner名称,不要照抄执行,会找不到你要重启的gitlab-runner的
# 重启gitlab-runner 就好了
docker exec -it gitlab-runner-xxx gitlab-ci-multi-runner restart
网友评论