gpt4 book ai didi

docker - AspNet Core无法在docker [“ASPNETCORE_ENVIRONMENT=Production”的生产环境中运行]

转载 作者:行者123 更新时间:2023-12-02 21:13:18 24 4
gpt4 key购买 nike

我似乎无法使用ASPNETCORE_ENVIRONMENT = Production使我的aspnet核心应用程序在docker中运行,但是当我将环境改回Development时它可以工作。在生产环境中,我无法浏览到localhost:port,但在dev中工作正常。我的撰写文件如下:

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 json。那就是您的配置文件名称应为 AppSettings.Production.json 。因为您已将环境更改为生产环境。

{
"ConnectionStrings": {
"DefaultConnection": "Server=dbserver;Database=demoDb;User=sa;Password=MyStrong!Pass;"
},
"Portal_IP": "http://localhost",
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

关于docker - AspNet Core无法在docker [“ASPNETCORE_ENVIRONMENT=Production”的生产环境中运行],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53009208/

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