Gitlab-runner流水线报错,无法找到ca.pem文件

Gitlab-runner流水线报错,无法找到ca.pem文件

Deng YongJie's blog 321 2022-08-27

gitlab-runner流水线报错,无法找到ca.pem文件

https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27384

报错:

unable to resolve docker endpoint: open /certs/client/ca.pem: no such file or directory

image-20221228155608346

解决方法:

原因是没有足够的时间生成ca.pem文件,脚本命令执行太快,所以就会导致没有找到ca文件。

需要在ci.yaml,执行第一个docker命令之前,睡眠10秒。

然后加上ls /certs目录,更直观的看到是否存在ca文件

    script:
        - echo "The current REGISTRY_HOST is set to ${REGISTRY_HOST_VAR} ,CI_COMMIT_TAG is set to ${CI_COMMIT_TAG},I_COMMIT_BRANCH is set to ${CI_COMMIT_BRANCH},CI_COMMIT_REF_NAME is set to ${CI_COMMIT_REF_NAME}"
        - sleep 10   #增加睡眠
        - ls -R /certs/client    #查看目录是否有ca文件
        - docker login ${REGISTRY_HOST_VAR} -u ${REGISTRY_USER_VAR} -p ${REGISTRY_TOKEN_VAR}
        - sleep 3
        - docker build -t ${REGISTRY_HOST_VAR}/${CI_PROJECT_NAMESPACE}/${IMG_NAME}:${CI_COMMIT_TAG} .
        - docker push ${REGISTRY_HOST_VAR}/${CI_PROJECT_NAMESPACE}/${IMG_NAME}:${CI_COMMIT_TAG}


image-1676529153172

image-20221228161254640