Docker Run 设置环境变量

Docker Run

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

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

 

猜你喜欢

转载自www.cnblogs.com/lishidefengchen/p/10688259.html