Docker Community Forums

Share and learn in the Docker community.

Issue Connecting Visual Studio for Mac with mssql linux on Dokcer 2.0.0.3

I am using Docker for debugging asp.net core 2.2 apps on visual studio for Mac 2019

i created a container for mssql server - linux (latest version) on Docker and i was able to connect to the database from Azure Data Studio

but when trying to connect to the database from Visual Studio for Mac am getting an error:

“One or more errors occurred. (A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server))”

Finally I got the solution after a lot of time.

the solution was that Visual Studio for Mac is running app on a docker container for debugging and it was trying to connect to mssql on another docker container. The issue is that visual studio was not able to connect through “localhost” because it is trying to connect from one container to another.

putting the name of ms sql container as a server name in the connection string was the right way to solve it.

i hope my solution to help other developers.