mar*_*ark 13 azure docker azure-web-app-service
但日志窗格显示错误:
2020-02-11 06:31:40.621 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2020-02-11 06:31:41.240 INFO - Stoping site app505-dfpg-qa2-web-eastus2-gateway-apsvc because it failed during startup.
2020-02-11 06:36:05.546 INFO - Starting container for site
2020-02-11 06:36:05.551 INFO - docker run -d -p 9621:8081 --name app505-dfpg-qa2-web-eastus2-gateway-apsvc_0_a9c8277e_msiProxy -e WEBSITE_SITE_NAME=app505-dfpg-qa2-web-eastus2-gateway-apsvc -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=app505-dfpg-qa2-web-eastus2-gateway-apsvc.azurewebsites.net -e WEBSITE_INSTANCE_ID=7d18d5957d129d3dc3a25d7a2c85147ef57f1a6b93910c50eb850417ab59dc56 appsvc/msitokenservice:1904260237
2020-02-11 06:36:05.552 INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2020-02-11 06:36:17.766 INFO - Pulling image: a...cr/gateway:1.0.20042.2
2020-02-11 06:36:17.922 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"pull access denied for a...cr/gateway, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}
2020-02-11 06:36:17.923 ERROR - Pulling docker image a...cr/gateway:1.0.20042.2 failed:
2020-02-11 06:36:17.923 INFO - Pulling image from Docker hub: a...cr/gateway:1.0.20042.2
2020-02-11 06:36:18.092 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"pull access denied for a...cr/gateway, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}
2020-02-11 06:36:18.094 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2020-02-11 06:36:19.062 INFO - Stoping site app505-dfpg-qa2-web-eastus2-gateway-apsvc because it failed during startup.
Run Code Online (Sandbox Code Playgroud)
用于部署应用服务的服务主体具有对容器注册表的父资源组的 AcrPush 访问权限:
设置存在:
我az login
用那个服务主体做了,然后尝试az acr login
注册。它工作正常。那么我在这里错过了什么?
编辑 1
我刚刚从应用服务配置中复制了值并粘贴到控制台上。docker登录没有问题。
它一定是别的东西。
编辑 2
但是,我也得到了这个:
C:\Dayforce\fintech [shelve/terraform ?]> docker pull a...r/gateway
Using default tag: latest
Error response from daemon: pull access denied for a...r/gateway, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Run Code Online (Sandbox Code Playgroud)
所以,我可以登录,但不能拉。很奇怪,因为账户被配置为可以AcrPush
访问容器,其中包括AcrPull
:
编辑 3
我更新了管道,但仍然出现相同的错误:
2020-02-11 16:03:50.227 ERROR - Pulling docker image a...r.azurecr.io/gateway:1.0.20042.2 failed:
2020-02-11 16:03:50.228 INFO - Pulling image from Docker hub: a...r.azurecr.io/gateway:1.0.20042.2
2020-02-11 16:03:50.266 ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://a...r.azurecr.io/v2/gateway/manifests/1.0.20042.2: unauthorized: authentication required"}
2020-02-11 16:03:50.269 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2020-02-11 16:03:50.853 INFO - Stoping site app505-dfpg-qa2-web-eastus2-gateway-apsvc because it failed during startup.
Run Code Online (Sandbox Code Playgroud)
编辑 4
我发现工作的唯一方法是在 ACR 上启用管理员用户并在 DOCKER_... 变量中传递其凭据而不是服务主体的凭据。
这令人沮丧,我知道服务主体可以在本地运行时登录和拉取,这是一个谜,为什么它不适用于在应用服务主机上运行的 docker。我们这里有另一个团队面临同样的问题,他们没有找到任何解决方案,但启用了管理员用户。
编辑 5
整个过程作为 Azure DevOps 本地发布管道的一部分使用专用服务主体运行。让我称之为 Pod Deploy Service Principal 或简称SP。
让我们DOCKER_xyz
表示控制在应用服务主机上运行的 docker 的三个应用设置:
DOCKER_REGISTRY_SERVER_URL
DOCKER_REGISTRY_SERVER_USERNAME
DOCKER_REGISTRY_SERVER_PASSWORD
我认为我们需要在这里区分两个部分:
DOCKER_xyz
应用程序设置。我认为DOCKER_xyz
应用程序设置不是为了那个,而是为了第二部分。DOCKER_xyz
应用程序设置。我的问题是第 (1) 部分效果很好,但即使DOCKER_xyz
应用设置从第 (1) 部分中指定了 SP 的凭据,第(2) 部分也不会。如果我指向DOCKER_xyz
ACR 的管理员用户,我可以让它工作的唯一方法。
但这为什么在地球上DOCKER_xyz
应用程序设置不能指向管道 SP,这对于第 (1) 部分来说已经足够好了?
编辑 6
目前的情况是这样。除了使用 ACR 管理员用户和密码之外,Azure 应用服务无法与 ACR 通信。因此,即使在应用服务主机上运行的 docker 运行时可能知道如何使用任何服务主体登录,应用服务也不会使用任何身份或服务主体从 ACR 读取元数据——只有管理员用户和密码。相关参考资料如下:
就个人而言,我发现 Microsoft 建议不要使用 ACR 管理员用户这一点令人惊讶,但他们产品的一个非常核心的部分,即 Azure 应用服务,取决于它是否被启用。让我想知道微软的不同团队是否知道其他人在做什么或不做什么......
经过大量研究后,我找到了一种无需启用管理员用户即可解决此问题的方法
Run Code Online (Sandbox Code Playgroud)DOCKER_REGISTRY_SERVER_PASSWORD with Client Secret of app registration which was saved in the first step DOCKER_REGISTRY_SERVER_USERNAME with client Id of App registration
这应该可以解决 Docker Api 异常。
令人费解的是,任何 Azure 容器注册表文档都没有提及这一点。尽管我认为 AAD 文档中的某个地方间接提到了这一点。
为我完成这些步骤后,应用服务开始拉动。:D
祝你好运 :)
根据我在演讲中收到的消息,让我来解答您对错误的困惑。
我猜您通过Azure门户将ACR中的图像部署到Web应用程序。当您使用 Azure 门户从 ACR 部署 Web 应用程序时,它只允许您选择 ACR 以及图像和标记,但不允许您设置凭据。这样,如果启用管理员用户,Azure 将自行设置管理员用户和密码。如果您不启用它,则会发生您收到的错误。
如果您想使用服务主体,我建议您使用其他工具,例如 Azure CLI。然后您可以使用命令自行设置 docker 注册表凭据az webapp config container set
。
这是示例,在我这边效果很好:
使用 Azure CLI,您可以按照此处的步骤进行操作。
更新:
以下是我这边测试的截图:
归档时间: |
|
查看次数: |
10191 次 |
最近记录: |