.Net core console app reads config file on main like below.
static void Main(string[] args)
{
var configBuilder = new ConfigurationBuilder()
.AddJsonFile("//home/processorconfig/appsettings.json");
var configuration = configBuilder.Build();
...
}
When I run docker image with -v parameter
docker run -v C:\Configs\:/home/processorconfig/ -it 858a565b2069
output is:
Specify --help for a list of available options and commands.
When I change just a letter in volume parameter it runs container but app gets exception
docker run -v C:\Configs\:/home/processorconfg/ -it 858a565b2069
Output:
Unhandled Exception: System.IO.FileNotFoundException: The configuration file 'processorconfig/appsettings.json' was not found and is not optional. The physical path is '/home/processorconfig/appsettings.json'. at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
When I change console app AddJsonFile path to another, and then add volume to the path on run, I got same output.
Any help would be appreciated.
Same result with --mount
parameter
Update: Found a clue that when I delete appsetings.json in C:\Configs it runs container and get exception message.