我正在按照这个链接创建我的第一个docker映像,它成功了,现在我试图从这个链接将这个映像推到我的docker存储库中。但是每当我试图将这个映像推入存储库时,我就会得到这种类型的错误。
denied: requested access to the resource is denied
注:我已成功登录docker
我正在按照这个链接创建我的第一个docker映像,它成功了,现在我试图从这个链接将这个映像推到我的docker存储库中。但是每当我试图将这个映像推入存储库时,我就会得到这种类型的错误。
denied: requested access to the resource is denied
注:我已成功登录docker
当前回答
我在Azure管道中遇到了类似的问题。我错过了在repository部分添加docker-id。
在Azure中,在推送时,如果仅使用名称,例如<repo-name>,可能无法工作。它需要完全限定的回购名称,其中还包括docker-id。
Use
repository: '<docker-id>/<repo-name>'
而不是
repository: '<repo-name>'
管道代码片段:
- task: Docker@2
inputs:
containerRegistry: 'service-connection-name'
repository: '<docker-id>/<repo-name>'
其他回答
您可能需要在docker push之前将docker repo切换为private。
感谢Dean Wu提供的答案和ses的评论,在推送之前,请记得注销,然后从命令行登录到您的docker hub帐户
# you may need log out first `docker logout` ref. https://stackoverflow.com/a/53835882/248616
docker login
根据文件:
You need to include the namespace for Docker Hub to associate it with your account.
The namespace is the same as your Docker Hub account name.
You need to rename the image to YOUR_DOCKERHUB_NAME/docker-whale.
所以,这意味着你必须在推送之前标记你的图像:
docker tag firstimage YOUR_DOCKERHUB_NAME/firstimage
然后你就可以推它了。
docker push YOUR_DOCKERHUB_NAME/firstimage
Docker对私有存储库的数量也有限制。如果您正在通过从本地机器推入创建私有存储库,则它将创建存储库,但不能再向其推入或从其拉出任何其他内容,并且您将得到“对资源的请求访问被拒绝”错误。
在Azure Devops中创建CI管道以构建docker映像并将其推送到docker Hub时,我也遇到了同样的问题。我所犯的错误是在容器存储库部分提供了错误的条目。
在buildAndPush任务中,我在容器存储库字段中给出存储库名称。实际上,存储库名称应该附加Docker Hub用户名/。 例如,您的用户名是myuser,存储库名称是test,然后提供myuser/test条目。一旦我纠正了这个问题,管道就成功地工作了,图像被推送到我的docker中心存储库
有一个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
以防其他人遇到这种情况-在我的情况下,原因是我正在使用(已弃用的)docker合成方法来推送图像。切换到预期的docker推送为我解决了这个问题。