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

denied: requested access to the resource is denied

注:我已成功登录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

其他回答

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

我在git上的问题是项目权限配置。 我已经通过启用“容器注册表”在设置->通用->可见性,项目功能,权限和启用容器注册表为我的项目(链接):

我也有这个问题。事实证明,我使用的是免费层,并试图在私有存储库中推送多个图像。将一张图片设为私有,其余的设为公共,这对我来说很管用。

我带着同样的信息来到这里,但来自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登录后仍然失败,请确保您试图推送到的存储库在一开始就已创建。