Reputation: 109
Can anyone help with the next issue:
In My application (Asp Net Core 3.1) I have the next connection string
I should create some containers, which have different connection strings but the same image.
I wrote next docker run command (windows server) :
docker run --rm --name admin -it -d -p 8080:8080 qulix/admin -e "ConnectionString:MSSQL"="Server=<IP adress>;Database=BasketballDb;User Id=user;Password=123456;Trust_connection=false"
and connection string didn't change. I don't understand why but I start to read about environment variables but I don't correctly understand how it should help me.
Update
If I change a location it read it as the image name and get the next error
C:\Program Files\Docker\Docker\resources\bin\docker.exe: invalid reference format: repository name must be lowercase.
Upvotes: 0
Views: 2225
Reputation: 109
My solution was (in windows docker server) next line:
docker run --rm --name stat -it -d -p 8090:8080 -e ConnectionStrings:MSSQL="Server=<IP Adress>;Database=Basketball_stat;User Id=user;Password=123456;" admin
where
ConnectionStrings:MSSQL
should be without any quotes
"Server=<IP Adress>;Database=Basketball_stat;User Id=user;Password=123456;"
with quotes(double or single)
admin
is the name of repository
Upvotes: 0
Reputation: 59936
Anything passes after image name in docker run
command it considers as a parameter to entrypoint.
so try to rearrange the docker run command.
docker run --rm -e "ConnectionString:MSSQL\"=\"Server=<IP adress>;Database=BasketballDb;User Id=user;Password=123456;Trust_connection=false" qulix/admin
Also I am not sure your code part, you can look into this
asp.net core override connection strings via ENV variables
As consuming environment variable is something that depends on the codebase or framework.
Upvotes: 3