英文:
Gitlab registry images not getting pulled in Gitlab CI progcess
问题
我使用/kaniko/executor构建镜像并推送到gitlab容器注册表(参考下面的脚本)。镜像已创建并复制到容器注册表。
现在我在不同项目的gitlab-ci流程中使用此基础镜像,但遇到以下错误。
警告/错误日志片段:
警告:无法拉取策略为""的镜像:拉取镜像失败:rpc错误:代码=未知描述=无法拉取和解压缩镜像"registry.gitlab.com/
错误:作业失败:准备环境:等待容器运行中:拉取镜像"registry.gitlab.com/
.gitlab-ci.yaml文件代码用于创建镜像并推送到容器注册表:
变量:
GIT_STRATEGY: clone
IMAGE_VERSION: v1.0.0
默认:
标签:
- 应用程序
阶段:
- 构建
构建gitlab容器:
阶段:构建
镜像:
名称:gcr.io/kaniko-project/executor:debug
入口点:[""]
脚本:
- echo "{"auths":{"$CI_REGISTRY":{"username":"$CI_REGISTRY_USER","password":"$CI_REGISTRY_PASSWORD"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$IMAGE_VERSION
英文:
I am using /kaniko/executor to build the image and push to gitlab container registry (refer below script ). Image getting created and copied to container registry.
Now I am using this base image into gitlab-ci process of different project with image tag but getting below error.
**Warning/Error log snippet : **
WARNING: Failed to pull image with policy "": image pull failed: rpc error: code = Unknown desc = failed to pull and unpack image "registry.gitlab.com/<project-path>:v1.0.0": failed to resolve reference "registry.gitlab.com/<project-path>:v1.0.0": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
ERROR: Job failed: prepare environment: waiting for pod running: pulling image "registry.gitlab.com/<project-path>:v1.0.0": image pull failed: rpc error: code = Unknown desc = failed to pull and unpack image "registry.gitlab.com/<project-path>:v1.0.0": failed to resolve reference "registry.gitlab.com/<project-path>:v1.0.0": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
.gitlab-ci.yaml file code to create image and push to container registry:
variables:
GIT_STRATEGY: clone
IMAGE_VERSION: v1.0.0
default:
tags:
- applications
stages:
- build
build_gitlab_container:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$IMAGE_VERSION
So far I have validated below options
- Incorrect repository URL : My repository is correct
- Authorization details
- Insufficient scope - I am owner of this gitlab subgroup and project.
答案1
得分: 1
我遇到了一个新项目的同样问题。
转到设置 > CI/CD > 令牌访问
以获取基础图像项目,并添加到您的目标项目中。
记得从路径中删除/
。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论