appsettings.json holds default application settings shared across environments. .NET merges it with an environment-specific file such as appsettings.Development.json or appsettings.Test.json, then applies environment-variable overrides. section 18.2
A typical configuration hierarchy combines:
- appsettings.json for baseline values. section 18.2
- appsettings.{Environment}.json for environment-specific overrides. section 18.2
- Environment variables for selecting the environment and overriding settings. section 18.2
Run the same image with different settings
Run the image normally to use the default Development environment, or set DOTNET_ENVIRONMENT=Test to merge appsettings.json with appsettings.Test.json. Both configurations can remain inside the Docker image. section 18.2
# run the to-do list app with default config: docker run -d -p 8083:8080 diamol/ch18-todo-list:2e # run the app with the config for the test environment: docker run -d -p 8084:8080 ` -e DOTNET_ENVIRONMENT=Test diamol/ch18-todo-list:2e
Use the commands to start the application with default or test configuration. section 18.2
