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

denied: requested access to the resource is denied

注:我已成功登录docker


当前回答

有时,当您已经使用另一个帐户登录时,可能会遇到此问题。在这些情况下,你必须:

docker logout

然后

docker login  

其他回答

以防其他人遇到这种情况-在我的情况下,原因是我正在使用(已弃用的)docker合成方法来推送图像。切换到预期的docker推送为我解决了这个问题。

您可能需要在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

我在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>'

如果您已经登录,如果您仍然得到错误。请按照步骤操作,

PS C:\Users\rohit\Docker> docker logout
Removing login credentials for https://index.docker.io/v1/

PS C:\Users\rohit\Docker> docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: rohithpoya
Password:*****************
Login Succeeded

Logging in with your password grants your terminal complete access to your account.
For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/

PS C:\Users\rohit\Docker> docker push rohithpoya/mongo-enterprise:5                                                                                                                                                                       
The push refers to repository [docker.io/rohithpoya/mongo-enterprise]                                                                                                                                                                        83ee27b8fe98: Pushed

我也有同样的问题。我强烈推荐大家浏览一下这个博客。

我的问题更多地与ACR有关。Docker客户端将引用配置。您的SP证书文件将存储在json文件中(角色所有者)。

博客中帮助我解决问题的部分有:

Docker镜像ls Docker标签.azurecr.io/:v1 Docker推送.azurecr.io/:v1

在此操作之前,我还创建了一个具有所有者特权的SP。