gpt4 book ai didi

azure - Azure上的Docker compose webapp无法访问

转载 作者:可可西里 更新时间:2023-11-01 11:23:42 25 4
gpt4 key购买 nike

我的应用程序已在本地成功构建,可在 http://localhost:5000 上运行但部署在 Azure 上时则不然:

version: '3'
services:
redis:
image: redis:alpine
ports:
- "6379:6379"

web:
build: .
image: myappregistry.azurecr.io/myapp:latest
ports:
- "5000:5000"

在 Azure 上编写它似乎也可行:


2019-03-30 13:25:51.864 INFO - Starting multi-container app, configuration =
version: '3'
services:
redis:
image: "redis:alpine"
ports:
- "6379:6379"

web:
build: .
image: myappregistry.azurecr.io/myapp:latest
ports:
- "5000:5000"

2019-03-30 13:25:54.668 INFO - Issuing docker pull redis:alpine
2019-03-30 13:25:57.223 INFO - docker pull returned STDOUT>> alpine: Pulling from library/redis
Digest: sha256:a228f66132cd46a53fd818443c42458af5d6a3e1231df25184304b8e732e51c4
Status: Image is up to date for redis:alpine

2019-03-30 13:25:57.245 INFO - Starting container for site
2019-03-30 13:25:57.247 INFO - docker run -d -p 19446:6379 --name myapp003_redis_0 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITES_PORT=5000 -e WEBSITE_SITE_NAME=myapp003 -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=c04d15b1b0966eeeb73c65719c2b7ecac5f6223333efd04b1712f559b5660459 redis:alpine

2019-03-30 13:25:57.249 INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2019-03-30 13:25:58.084 INFO - Starting container for site
2019-03-30 13:25:58.086 INFO - docker run -d -p 0:5000 --name myapp003_web_0 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITES_PORT=5000 -e WEBSITE_SITE_NAME=myapp003 -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=c04d15b1b0966eeeb73c65719c2b7ecac5f6223333efd04b1712f559b5660459 myappregistry.azurecr.io/myapp:latest

2019-03-30 13:25:58.088 INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.

但是,通过 https://myapp.azurewebsites.net/ 访问它失败并显示“502 - Web 服务器在充当网关或代理服务器时收到无效响应。”

注意,在 Azure Web 应用程序“应用程序设置”中,我设置了值

WEBSITES_PORT 5000

根据https://code.visualstudio.com/docs/python/tutorial-deploy-containers

知道可能出了什么问题吗?

最佳答案

我不是 Azure 专家,但查看您发布的日志,与您在本地测试的 docker-compose 相比,许多事情发生了变化:- redis 现在映射到 19446 而不是 6379- 容器不再在同一网络上运行(当使用 docker-compose 启动时,它们位于同一网络上,但不同的 docker run 命令不会以相同的方式运行)

因此,您收到的错误可能是由于容器之间的通信错误造成的。尝试仅上传您的网络应用程序并访问静态页面。如果可行,那么您应该重新审视如何从应用程序连接到 Redis 容器。

关于azure - Azure上的Docker compose webapp无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55432068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com