Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connection string for sqlserver in Docker container

I'm using Visual Studio 2017 for mac with dotnet Core and EF Core. After setting up the mssql image in Docker container , I was trying to add the connection string but throwing connection error. I tried with different options such as ip address , container name , host name etc. as server name but none of them worked.

 "Default": "Server=172.17.0.2; Database=ERPDb; User=sa; Password =******;" 

with container name

 "Default": "Server=ecstatic_hermann; Database=ERPDb; User=sa; Password=******;" 

with hostname :

 "Default": "Server=f45840a59623; Database=ERPDb; User=sa; Password=******;" 

While connecting through using localhost in Terminal its successfully connecting

$ mssql -s localhost -p Technocrat123 Connecting to localhost...done  sql-cli version 0.6.2 Enter ".help" for usage hints. 

But when running the application the connection fails.

Appreciate any help. Thanks in advance.

If using localhost then error is

Login failed for user ''. Reason: An attempt to login using SQL authentication failed. Server is configured for Integrated authentication only. 
like image 628
user2695433 Avatar asked Aug 16 '17 11:08

user2695433


People also ask

Can I run SQL Server in a Docker container?

You can now install SQL Server on Linux distributions like the RHEL, SUSE, Ubuntu, etc. However, in order to install and use SQL Server on a Mac, you need to run the Linux distribution inside a docker container.


1 Answers

sudo docker pull microsoft/mssql-server-linux:2017-latest docker run \   -e 'ACCEPT_EULA=Y' \   -e 'MSSQL_SA_PASSWORD=YourSTRONG!Passw0rd' \   -p 1401:1433 \   -n sql1 \   -d microsoft/mssql-server-linux:2017-latest 

then,

private static string _connStr = @"   Server=127.0.0.1,1401;   Database=Master;   User Id=SA;   Password=YourSTRONG!Passw0rd"; 
like image 197
rjminchuk Avatar answered Sep 30 '22 18:09

rjminchuk