Skip to main content
 首页 » 编程设计

python之在 azure 上使用 docker 镜像部署 python web 应用程序

2024年12月31日32kenshinobiy

我正在努力学习本教程 DEPLOY PYTHON WEB APP IN WEB APP FOR CONTAINERS

我已经克隆了该项目,对其进行了手动测试,并且运行良好。教程推荐将 docker 镜像推送到 docker hub 上。取而代之的是,我在 azure 本身上创建了容器注册表,并将 docker 镜像推送到 azure 容器注册表 中。我没有启用 azure container registry 中使用的管理员,因此无需担心凭据,因为它不是私有(private)注册表。

然后我使用了教程中提到的命令并启动了网络应用程序,但是当我尝试访问该 url 时,它显示 Service Unavailable。我不知道我在这里做错了什么。

请帮忙。谢谢

DOCKER文件

FROM tiangolo/uwsgi-nginx-flask:python3.6-alpine3.7 
 
ENV LISTEN_PORT=8000 
EXPOSE 8000 
 
COPY /app /app 

请您参考如下方法:

用于在 Azure 容器上部署 Web 应用程序。图像是导入 key 。

当图像在公共(public)注册表中时,您只需按照以下步骤操作:

  1. 在 Azure 中创建一个资源组。
  2. 制定服务计划。
  3. 使用图像创建 Web 应用程序。

有关详细信息,请参阅 Deploy a Docker/Go web app in Web App for Containers .

当镜像在私有(private)registry中时,这里以Azure Container Registry为例。

您还需要一步,像这样为您的网络应用设置容器配置:

az webapp config container set --name <app_name> --resource-group <resourceGroup_Name> --docker-custom-image-name <azure-container-registry-name>.azurecr.io/<image_name> --docker-registry-server-url https://<azure-container-registry-name>.azurecr.io --docker-registry-server-user <registry-username> --docker-registry-server-password <password> 

有关详细信息,请参阅 Use a Docker image from any private registry .