首页 > 解决方案 > 通过 Azure Devops 将 docker 映像部署到 Linux 上的 Web 应用程序失败

问题描述

我正在尝试web app for containers (Linux)通过Azure Devops. 我正在使用该任务Azure Web App for Containers来完成此任务。

在 Azure 中构建映像并将其推送到我的私有容器注册表工作正常。但是当我尝试部署我新建和推送的映像时,我收到了一个身份验证错误

Azure Devops 报告部署很顺利,但是当我container settings在 Azure 的选项卡中查看 docker 日志时,我看到了身份验证错误。如果我尝试直接在其中部署我的图像,container settings它会按预期工作。

以前我有我的 Azure 订阅的服务连接,我还为我的 Azure 容器注册表添加了一个单独的服务连接。我没有使用 docker compose,而是尝试部署单个图像/容器。

Azure Devops 日志:

2019-08-12T13:48:47.3512681Z ##[section]Starting: Azure Web App on Container Deploy: my-service
2019-08-12T13:48:47.3676562Z ==============================================================================
2019-08-12T13:48:47.3676709Z Task         : Azure Web App for Containers
2019-08-12T13:48:47.3676775Z Description  : Deploy containers to Azure App Service
2019-08-12T13:48:47.3676828Z Version      : 1.0.22
2019-08-12T13:48:47.3676870Z Author       : Microsoft Corporation
2019-08-12T13:48:47.3676932Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-containers
2019-08-12T13:48:47.3677003Z ==============================================================================
2019-08-12T13:48:47.6472308Z Got service connection details for Azure App Service:'my-service'
2019-08-12T13:48:48.7565776Z Single-container Deployment to the webapp 'my-service' as only the image detail was sepcified.
2019-08-12T13:48:49.2180101Z Updating App Service Configuration settings. Data: {"appCommandLine":null,"linuxFxVersion":"DOCKER|my-registry.azurecr.io/my-repository:latest"}
2019-08-12T13:48:51.1744261Z Updated App Service Configuration settings.
2019-08-12T13:48:51.1752210Z Restarting App Service: my-service
2019-08-12T13:48:51.6881923Z App Service 'my-service' restarted successfully.
2019-08-12T13:48:54.9987139Z Successfully updated deployment History at https://my-service.scm.azurewebsites.net/api/deployments/12431565617733135
2019-08-12T13:48:55.5252693Z App Service Application URL: https://my-service.azurewebsites.net
2019-08-12T13:48:55.5391444Z ##[section]Finishing: Azure Web App on Container Deploy: my-service

在此处输入图像描述

Docker 登录 Azure:

2019-08-12 07:54:11.184 INFO  - Pulling image: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:11.424 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for my-registry.azurecr.io/my-service:20190812.8 not found: manifest unknown: manifest unknown"}

2019-08-12 07:54:11.425 ERROR - Pulling docker image my-registry.azurecr.io/my-service:20190812.8 failed:
2019-08-12 07:54:11.426 INFO  - Pulling image from Docker hub: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:11.461 ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://my-registry.azurecr.io/v2/my-service:/manifests/20190812.8: unauthorized: authentication required"}

2019-08-12 07:54:11.463 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2019-08-12 07:54:13.482 INFO  - Pulling image: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:13.588 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for my-registry.azurecr.io/my-service:20190812.8 not found: manifest unknown: manifest unknown"}

2019-08-12 07:54:13.593 ERROR - Pulling docker image my-registry.azurecr.io/my-service:20190812.8 failed:
2019-08-12 07:54:13.593 INFO  - Pulling image from Docker hub: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:13.628 ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://my-registry.azurecr.io/v2/my-service:/manifests/20190812.8: unauthorized: authentication required"}

2019-08-12 07:54:13.629 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2019-08-12 07:54:17.116 INFO  - Pulling image: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:17.244 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for my-registry.azurecr.io/my-service:20190812.8 not found: manifest unknown: manifest unknown"}

2019-08-12 07:54:17.245 ERROR - Pulling docker image my-registry.azurecr.io/my-service:20190812.8 failed:
2019-08-12 07:54:17.246 INFO  - Pulling image from Docker hub: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:17.281 ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://my-registry.azurecr.io/v2/my-service:/manifests/20190812.8: unauthorized: authentication required"}

2019-08-12 07:54:17.283 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)

有人遇到过同样的问题吗?即使我在 Azure Devops 中添加了服务连接,我是否明确需要向注册表提供凭据?

标签: linuxazuredockerazure-devopsazure-pipelines-release-pipeline

解决方案


作为最后的手段,我通过在 Azure Devops 中删除与订阅的服务连接并将其添加回来,让它神奇地工作。(无需为您的 Azure 容器注册表提供单独的服务连接)

非常令人沮丧!


推荐阅读