首页 > 解决方案 > 拒绝:将图像推送到 gitlab 注册表时请求的资源访问被拒绝

问题描述

我正在尝试将图像推送到 gitlab 注册表。

我已经做过很多次了,所以我想知道为什么会出现这个错误。

我用最新标签构建图像:

Successfully tagged registry.gitlab.com/mycompany/rgpd_api:latest

然后我登录并推送:

docker login registry.gitlab.com -u gitlab+deploy-token-91931 
docker push registry.gitlab.com/mycompany/rgpd_api:latest

但我得到:

The push refers to repository [registry.gitlab.com/mycompany/rgpd_api]
be679cc302b9: Preparing 
denied: requested access to the resource is denied

我给了gitlab+deploy-token-91931令牌read_repositoryread_registry权利。

我的回购是:

https://gitlab.com/mycompany/rgpd_api

我检查了文档页面:https ://docs.gitlab.com/ee/user/project/container_registry.html

但是当我通过 Gitlab CI 进行操作时,使用gitlab-ci-token

我可以正常推。

我也尝试重新生成一个新令牌,但仍然是同样的问题。

我该如何解决?

标签: dockergitlabregistrygitlab-ci

解决方案


我的错误是使用部署令牌将图像推送到注册表。

部署令牌可用于拉取镜像,但不能推送。

因此,您可以生成个人访问令牌。您应该至少添加权限:

read_registry, write_registry

推荐阅读