A .NET (web) app has a configuration file for each environment (appsettings.EnvironmentName.json). The application determines which environment it runs in through the ASPNETCORE_ENVIRONMENT, the DOTNET_ENVIRONMENT environment variable or through other means. Because of that, one build/publish of an application is able to run in every environment. But how does that work in a Docker container?
The answer is a lot shorter than the introduction. The -e flag sets the environment variables:
The answer is a lot shorter than the introduction. The -e flag sets the environment variables:
docker run -dp 8081:80 -e "DOTNET_ENVIRONMENT=Production" image:tag