简体   繁体   中英

Docker-compose doesnt set environment variable

I have a project with a launchSettings.json file where we specify the environment like this: "Environment": "Production"

When i use docker-compose and set the env. variable to "Development", the project still picks up "Production". If i remove the line in launchSettings.json file the project picks the correct variable ("Development" in this case).

i run the project in docker via dotnet run So my guess is that when i use dotnet run, the launchsettings override the env. variable.

Is there a way to prevent this from happening? (maybe publishing the package and running the dll directly?)

I would like to just use a docker-compose file to set the env. variable

As per: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.1

The environment for local machine development can be set in the Properties\\launchSettings.json file of the project. Environment values set in launchSettings.json override values set in the system environment.

In this post it shows a number of ways you can specify which environment you are currently running in.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM