Docker Run

We can then override the environment variables set in the Docker file when running the image by using the -e flag:

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
Docker run -e "EmailServer=192.168.0.1" myimage

 

对应.netcore应用程序,设置 ASPNETCORE_ENVIRONMENT 环境变量为自定义的值,就会寻找对应的配置文件,默认不设置会加载appsettings.json

Docker run -e "ASPNETCORE_ENVIRONMENT=development" myimage

参考:

https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/environments?view=aspnetcore-2.2

https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/host/web-host?view=aspnetcore-2.2#set-up-a-host

https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/index?view=aspnetcore-2.2#json-configuration-provider

https://www.scottbrady91.com/Docker/ASPNET-Core-and-Docker-Environment-Variables

https://andrewlock.net/how-to-set-the-hosting-environment-in-asp-net-core/

http://www.cnblogs.com/dudu/p/6985313.html

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄