A volume makes a host folder or file available inside a container at a chosen path. It provides a practical way to supply external configuration and secrets without embedding them in the image. section 13.5
When using volumes for configuration, keep these runtime behaviors in mind:
- Mount a target folder separate from existing image content, because the mount can overwrite files already there. section 13.5
- Read mounted JSON with an optional configuration source, such as /settings/secrets.json. section 13.5
- Use mounted volumes to keep secrets separate from ordinary application configuration. section 13.6
Listing 13.24 Adding optional file configuration source
builder.Configuration.AddJsonFile(
"/settings/secrets.json", #1
optional: true); #2
builder.Services.Configure<CosmosDbSettings>( #3
builder.Configuration.GetSection("CosmosDbSettings"));
var app = builder.Build();
Adds an optional JSON configuration source for a secrets file mounted at /settings/secrets.json. section 13.5







