【发布时间】:2020-02-16 14:08:06
【问题描述】:
我是 Azure 的新手,这是我在 StackOverflow 上的第一个问题。我在使用 Docker Compose 使用多容器 Docker (Linux) 部署新的 Azure 应用服务时遇到问题。不幸的是,我无法访问我的应用程序日志,因为存在未知错误。我只更改配置以使用我的私有注册表和docker-compose 配置,其他设置保持默认。我正在使用 Azure for Students 计划,因此无法选择加入 1:1 专家支持。
我的应用服务基本上由 4 个容器组成:webservice (Django REST Framework)、comprof (VueJS)、raspisample (Express) 和 db (PostgreSQL)。我正在使用 GitLab 的 Docker Registry (registry.gitlab.com),它是一个私有注册表(图像不公开)。这是我的docker-compose.yml 文件。
version: '3'
services:
webservice:
image: registry.gitlab.com/something/webservice:latest
restart: always
working_dir: /opt/webservice
environment:
- DEBUG=false
- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
- PREDICTOR_URL=https://something-predictor.azurewebsites.net
- CACHE_DIR=/var/cache
- SECRET_KEY="**omitted**"
- LOG_DIR=/var/log/webservice
- UPLOADS_DIR=/var/uploads
- ACCESS_LOG=/var/log/webservice/access_main.log
- ERROR_LOG=/var/log/webservice/error_main.log
ports:
- "81:80"
volumes:
- webservice_data:/var/log/webservice
- webservice_data:/var/cache
- webservice_data:/var/uploads
depends_on:
- db
networks:
internal:
comprof:
image: registry.gitlab.com/something/company-profile:latest
restart: always
working_dir: /opt/comprof
environment:
- WEBSERVICE_URL=http://webservice:81
- RASPI_SAMPLE_URL=http://raspisample:82
- PREDICTOR_URL=https://something-predictor.azurewebsites.net
- ACCESS_LOG=/var/log/comprof/access_main.log
- ERROR_LOG=/var/log/comprof/error_main.log
ports:
- "80:80"
- "443:443"
volumes:
- comprof_data:/var/log/comprof
depends_on:
- webservice
networks:
default:
internal:
raspisample:
image: registry.gitlab.com/something/local-webservice:latest
restart: always
working_dir: /opt/sample
environment:
- WEBSERVICE_URL=http://webservice
- ACCESS_LOG=/var/log/raspi/access_main.log
- ERROR_LOG=/var/log/raspi/error_main.log
ports:
- "82:3000"
volumes:
- raspisample_data:/var/log/raspi
networks:
internal:
db:
image: postgres
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
volumes:
- db_data:/var/lib/postgresql/data
networks:
internal:
networks:
default:
internal:
internal: true
volumes:
webservice_data:
raspisample_data:
comprof_data:
db_data:
此docker-compose 配置仅在我的 Azure 应用服务中失败。我的大学里有另一个虚拟机,这个配置在那里工作得很好。我也试过在我自己的笔记本电脑上,它也可以正常工作。在 Azure 中,错误消息如下:
:( Application Error
If you are the application administrator, you can access the diagnostic resources.
当我尝试在应用设置 > 容器设置 > 日志中解决此问题时,它显示了这一行错误:
Error in retrieving logs.
通过 Log Streams 访问日志时,我也检索到相同的错误。我在应用服务日志菜单上启用了应用程序日志,但它没有任何效果。我也无法访问 Azure 建议的 Docker 日志链接,它只会永远加载并在加载 15 分钟后返回连接超时错误。
问题是:我的docker-compose.yml 有什么问题吗?或者我的 Azure 应用服务的配置有什么问题吗?谢谢。
【问题讨论】:
-
您的应用服务使用哪个操作系统? linux还是windows?
-
你的项目使用什么语言?
-
@BowmanZhu 我正在使用 Linux。我对
webservice使用Python (Django),对comprof和raspisample使用JavaScript (Node/Vue.js)。在comprof,我也使用 Nginx。 -
您好,我遇到了类似的问题。你有没有得到任何地方?
-
在 linux 容器上运行的 Java 应用程序也是如此
标签: docker-compose azure-web-app-service docker-container