I have a docker-compose with environment variables for the ConnectionString :
services:
nameservice:
...
environment:
ConnectionStrings__mysqlDatabase: "Server=db;Uid=root;Pwd=password;"
I have on the .NET side in a console program, an AppSettings file (.NET6):
{
"ConnectionStrings": {
"mysqlDatabase": "Server=localhost;Uid=root;Pwd=password;"
}
}
and my program.cs :
IConfiguration Config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
ConnectionStringConstant.mysqlDatabase = Config.GetConnectionString("mysqlDatabase");
my problem is that in docker after creating a container, it keeps the value in AppSettings (which is not good for production) and it does not take the value passed by the docker-compose file.
Can you help me?