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

denied: requested access to the resource is denied

注:我已成功登录docker


当前回答

我带着同样的信息来到这里,但来自Azure DevOps。

在我的例子中,我使用docker-compose,而不仅仅是docker,并在yaml中编写构建管道。

- task: DockerCompose@0
  displayName: 'Push services'
  inputs:
    azureSubscription: '$(Parameters.azureSubscriptionEndpoint)'
    azureContainerRegistry: '$(Parameters.azureContainerRegistry)'
    dockerComposeFile: '$(Parameters.dockerComposeFile)'
    additionalDockerComposeFiles: |
      docker-compose.release.yml
      docker-compose.ci.yml
    dockerComposeFileArgs: 'PublishFolder=publish'
    action: 'Push services'
    additionalImageTags: '$(Build.BuildId)'
    includeLatestTag: true

我得到的消息是明确地说,它正在尝试推送到docker。io,这不是我想要的。我本来打算把它送到我的Azure容器注册中心。

这里缺少的是输入下的这一行:

containerregistrytype: Azure Container Registry

上面构建yaml的现有管道向导根本没有这一行。 希望这能帮助其他人在Azure DevOps上绞尽脑汁。

其他回答

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

我也面临着同样的问题,我给我的图像名称为something/image-name,但我尝试了<docker-hub-username>/image-name,它就像一个魅力。

步骤1

Docker登录——username=jp9573

步骤2

Docker push jp9573/todo

之前我给了jaypatel/todo,我只是把它改成了用户名/图像模式。通过这种方式,我不需要标记图像或任何东西。我认为这对新人来说是一种很好的方式。

有一个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

在使用Gitlab注册表时,我还遇到了这个错误消息。不同之处在于,我试图从以前的构建中更改映像的名称。这里的问题是,推送图像的注册表不存在,因为图像的新名称与我组中的任何项目都不匹配。

TLDR:在Gitlab中,映像名称必须与项目名称匹配。

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

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