我正在按照这个链接创建我的第一个docker映像,它成功了,现在我试图从这个链接将这个映像推到我的docker存储库中。但是每当我试图将这个映像推入存储库时,我就会得到这种类型的错误。

denied: requested access to the resource is denied

注:我已成功登录docker


当前回答

我真的希望这能帮助到一些人(像我一样先看最终答案的人):

我不断地尝试输入

docker push user/repo/tag

而不是

docker push user/repo:tag

因为我也这样做了我的标签:

docker tag image user/repo/tag

...一切都毁了。

我真诚地希望你不要重蹈我的覆辙。我在这上面浪费了30分钟…

其他回答

有一个docker文件,要求是立即构建一个映像并将其推送到docker hub

登录Docker集线器 Sudo docker login -u your_username 输入密码 构建映像 Sudo docker build -t your_username/demorepo:1.0 上面没有提到图像名称,因为your_username/demorepo是一个 在docker中心回购。标签名称为1.0 推送图片 Sudo docker推送your_username/demorepo:1.0

将已经存在的图像推送到Docker中心

Login to the Docker hub sudo docker login -u your_username Enter password Tag your image(suppose your image is named as test_docker:1.0) sudo docker tag test_docker:1.0 your_username/demorepo:firstpush Above, firstpush is the tag name given to your image, test_docker with 1.0 Tag. IMPORTANT : (While tagging, the image name is not mentioned) Now in docker images you will have 2 images, one says test_docker 1.0 and the other your_username/demorepo firstpush Push the image sudo docker push your_username/demorepo:firstpush

之前的答案都是正确的,我只是想补充一个我看到没有提到的信息;

如果项目是私有项目,要正确地推送映像,必须配置个人访问令牌或启用read_registry key的部署令牌。

来源:https://gitlab.com/help/user/project/container_registry using-with-private-projects

希望这是有帮助的(如果问题是张贴到目前为止的时间)

Docker对私有存储库的数量也有限制。如果您正在通过从本地机器推入创建私有存储库,则它将创建存储库,但不能再向其推入或从其拉出任何其他内容,并且您将得到“对资源的请求访问被拒绝”错误。

简单的工作解决方案:

访问这里https://hub.docker.com/创建一个私有存储库,例如johnsmith/ PRIVATE -repository,这是您在构建映像时将用于映像的name / repository。

首先,docker登录 其次,我使用"docker build -t johnsmith/private-repository:01 ."来创建图像,并且我使用"docker images"来确认创建的图像,如下面这个黄色框中所示:(对不起,我不能粘贴表格格式,只能粘贴文本字符串)

johnsmith/private-repository(REPOSITORY) 01(TAD) c5f4a2861d6e(IMAGE ID) 2 days ago(CREATED) 305MB(SIZE)

第三,我使用docker push johnsmith/private-repository:01

完成了!

在我的例子中,sudo -E处理此消息失败。解决方案是提供访问do docker而不使用sudo(创建一个组docker,将(Jenkins)用户添加到组中,将组设置在/var/run/docker.sock上)。现在docker push不需要sudo了,而且可以工作。