Docker推送至Azure容器注册表:访问被拒绝

10

我正在尝试将图像推送到Azure容器注册表的实例中,但即使我已经成功登录,它仍然失败。

enter image description here

4个回答

27

标签需要是:

azure_registry_name.azurecr.io/container-name:tag

在我的情况下:

docker push sunlabregistry.azurecr.io/python

我已经写了一个完整的例子,介绍如何使用Microsoft Azure容器注册表和SDK CLI快速部署Docker容器。在这个例子中,你可以给你的容器镜像打标签并将其推送到上游。docker tag container-name sunlabregistry.azurecr.io/container-name:tagdocker push acidemomvp.azurecr.io/aci-tutorial-app:v1其余的步骤都在我的逐步教程中解释了。 - DragonBe
正常工作,谢谢。顺便说一句,如果您在阅读后使用sudo来到这里,它也可以作为普通用户使用。 - Michael Staples
这个方法很有效。你必须完整地指定容器注册表的名称。如果在Azure中跳过容器注册表的域名,你会得到提示,docker.io是默认使用的容器注册表。而实际上应该使用azurecr.io。 - Tore Aurstad
在Azure的“推送容器镜像”页面上的文档中并没有提到使用完整的URL,所以我一直很困惑,不知道发生了什么事情。 - undefined

3
在Batman的回复基础上,我需要按照这里描述的步骤进行操作:

https://learn.microsoft.com/en-us/azure/container-registry/container-registry-repository-scoped-permissions

特别是,容器的名称不能随便取。它需要与我们在容器注册表中创建“范围映射”时指定的仓库名称匹配。为了更具体,让我们列出从创建容器注册表到执行“docker push”的所有步骤:
  1. Create a "Container Registry", and copy the "Login server", which in the example given by Batman is sunlabregistry.azurecr.io, but I use the name my_registry.azurecr.io

  2. In this Container Registry, create a "Token".

  3. When creating the Token, we have a field called "Scope map". Click on "Create new"

  4. We will get a window where we have text fields "Repository" and "Permissions". We can indicate any name we want in the text field "Repository". Let this name be my_repository. In the permissions, I selected all, which includes content/read, content/write.

  5. Once the Scope map has been created, we can finally generate our "Token". In the token details, select password1 or password2, and select the Generate icon.

  6. After generating a password, copy and save it to a safe location. Azure let's you copy the full docker login command with the password included, something like:

    docker login -u MyToken -p my_password my_registry.azurecr.io
    
  7. Do docker login with the above command (maybe adding "sudo" at the beginning)

  8. Tag your image as follows:

    sudo docker image tag <container_id> 
    my_registry.azurecr.io/my_repository:my_version
    

    where my_version can be anything we want, but my_repository needs to match what we entered when creating the Token, in step 4 above.

  9. Push the tagged image as follows:

sudo docker push my_registry.azurecr.io/my_repository:my_version

1

首先,您需要使用 sunlabregistry.azurecr.io/python-app:v1 标记本地图像,然后使用 docker push /python-app:v1 命令进行推送。请确保提及标签。


0
在我的情况下,当我尝试从Visual Studio IDE发布到Azure容器注册表时,遇到了错误。原因是用户没有AcrPush角色,分配了角色后,我就能够发布了。这可以通过门户和CLI来完成。希望这对某些人有所帮助。
通过门户 -
在你的ACR的刀片(左侧菜单)中,点击“访问控制(IAM)”。 点击“+ 添加”>“添加角色分配”。 “添加角色分配”窗格将在右侧打开。
在“角色”下拉菜单中,选择AcrPush以允许用户将图像推送到注册表。如果用户还需要拉取图像,您可以考虑分配AcrPushPull角色。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接