liveBook · Manning

Appsettings.json

As explained in Learn Docker in a Month of Lunches, Second Edition

appsettings.json is a .NET configuration file conventionally containing default application settings for all environments.

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

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains file merging and override order, but does not descend into configuration-provider internals.
Examples
Uses Development and Test containers, DOTNET_ENVIRONMENT, diagnostics endpoints, and Docker image configuration files.
What it assumes
Assumes familiarity with .NET applications, Docker containers, and environment variables.
What you can do after
Operate containers with shared defaults and selected environment-specific settings using Docker environment variables.
How it connects
Connects appsettings.json with environment-specific configuration files, environment variables, Docker, and CI/CD.

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.