【发布时间】:2019-03-31 05:49:29
【问题描述】:
我似乎无法使用 ASPNETCORE_ENVIRONMENT=Production 让我的 aspnet 核心应用程序在 docker 中运行,但是当我将环境更改回 Development 时它可以工作。在生产中我无法浏览到 localhost:port 但在开发中工作正常。我的撰写文件如下:
version: '3.4'
services:
web:
container_name: aspdemo
image: user/aspdemo
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:22973;
- 'Logging:LogLevel:Default=Debug'
- 'Logging:LogLevel:System=Information'
- 'Logging:LogLevel:Microsoft=Information'
- 'ConnectionStrings:DefaultConnection=Server=dbserver;Database=demoDb;User=sa;Password=MyStrong!Pass;'
ports:
- "22973:22973"
networks:
default: {}
be:
aliases:
- tokenserver
networks:
be:
external:
name: backend
AppSettings.json
{
"ConnectionStrings": {
"DefaultConnection": "Server=dbserver;Database=demoDb;User=sa;Password=MyStrong!Pass;"
},
"Portal_IP": "http://197.254.91.254",
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
AppSettings.Development.json
{
"ConnectionStrings": {
"DefaultConnection": "Server=dbserver;Database=demoDb;User=sa;Password=MyStrong!Pass;"
},
"Portal_IP": "http://localhost",
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
【问题讨论】:
-
你能添加你的 appSettings.Production.json 和 appSettings.Development.json 吗?
-
@CelalYildirim 检查以上更新
-
您好,您找到解决问题的方法了吗?
标签: docker asp.net-core .net-core docker-compose dockerfile