1. Asp.net Core Environment

You can follow by this article from Microsoft to deeply understand about multi environment for .net core app.

But I can summary here:

Asp.net Core provides 3 environment stages: Production Staging and Development

and Your setting file will be stored at appsettings.{environment}.json

We need to set ASPNETCORE_ENVIRONMENT when build the application

Assume our application will have two deploys :

Production with appsettings.Production.json Staging with appsettings.Staging.json

2. Let start

Assume you have a new app which was created by dotnet new webapi — name dotnet_demo_webapi .

Firstly, you need to update Startup.cs file to load .json files.

Second, Add your Dockerfile maybe like below:

Finally, because we need to build 2 versions (Staging and Production) so we will use docker-compose.yml to manage servies, you can read docks here:

After that run docker-compose up --build -d to build images and run services.

Any questions you can comment below, thanks for reading.

Asp.net Core & Docker example:

https://github.com/jinhduong/dotnet-and-docker