我有本地监听端口 5000 的 docker 镜像。 我已将映像部署到 Azure 容器注册表。
然后我使用以下命令创建了 Azure 容器实例:
az container create --resource-group myResourceGroup --name aci-tutorial-app --image <acrLoginServer>/aci-tutorial-app:v1 --cpu 1 --memory 1 --registry-login-server <acrLoginServer> --registry-username <service-principal-ID> --registry-password <service-principal-password> --dns-name-label <aciDnsLabel> --ports 80
容器创建成功,但浏览器未响应 DNS 名称。日志如下所示。
PS C:\azure\ACIPythonAPI> az container logs --resource-group My-Container-RG --name mycontainer
[2022-01-10 08:33:36 +0000] [18] [INFO] Starting gunicorn 20.1.0
[2022-01-10 08:33:36 +0000] [18] [INFO] Listening at: http://0.0.0.0:5000 (18)
[2022-01-10 08:33:37 +0000] [18] [INFO] Using worker: sync
[2022-01-10 08:33:37 +0000] [25] [INFO] Booting worker with pid: 25
可能出现什么问题? docker中的端口定义不正确?如何排除故障?
与我的问题类似,我将图像文件中的公开端口更新为与天蓝色实例端口类似。它有效
我遇到了同样的问题。在您创建的容器内,应用程序正在侦听端口 5000。但是您的容器实例是使用端口 80 创建的,因此它不匹配。在此日期之前,容器映像不支持端口映射
因此,现在请确保容器中的端口与您在容器实例中设置的端口相匹配。