Skip to content

gitlab-runner 问题记录

解决gitlab-runner 推镜像到harbor私服报错

shell
$ echo "[MASKED]" | docker login -u admin --password-stdin http://10.10.220.110:8081
time="2025-06-24T08:46:39Z" level=info msg="Error logging in to endpoint, trying next endpoint" error="Get \"https://10.10.220.110:8081/v2/\": http: server gave HTTP response to HTTPS client"
Get "https://10.10.220.110:8081/v2/": http: server gave HTTP response to HTTPS client
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1

修改docker配置

shell
yanfa@m1:~$ vim /etc/docker/daemon.json

{
  "registry-mirrors": [
    "https://docker.m.daocloud.io/",
    "https://huecker.io/",
    "https://dockerhub.timeweb.cloud",
    "https://noohub.ru/",
    "https://dockerproxy.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://docker.nju.edu.cn",
    "https://xx4bwyg2.mirror.aliyuncs.com",
    "http://f1361db2.m.daocloud.io",
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn"
  ],
  "insecure-registries": ["10.10.220.110:8081"]
}

看你的runner是什么用户启动的,加入docker用户组

shell
# 添加用户到 docker 组 (需要管理员权限)
sudo usermod -aG docker gitlab-runner
newgrp docker

gitlab-runner直接报错

shell
Running with gitlab-runner 18.1.0 (0731d300)
  on runner-108 Nuj8ndN3z, system ID: s_95971add243f
Preparing the "shell" executor
00:00
Using Shell (bash) executor...
Preparing environment
00:01
Running on m1...
ERROR: Job failed: prepare environment: exit status 1. Check https://docs.gitlab.com/runner/shells/#shell-profile-loading for more information

要排查此错误,请检查 /home/gitlab-runner/.bash_logout 。例如,如果 .bash_logout 文件包含如下所示的脚本部分,请将其注释掉并重新启动管道:

Shell
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi

文章来源于自己总结和网络转载,内容如有任何问题,请大佬斧正!联系我