Connect to Microsoft SQL localhost database from Docker container with Docker Desktop for Windows

-1

I've got a .NET Core 2.2 Web Application running on my Windows machine trying to communicate with my Microsoft SQL localhost database.

I'm using the following command to generate a container from my image

docker run -d -p 3000:80 --name dockerdemocontainer dockerdemoimage

but then I get a 500 internal server error when I try to hit my endpoints on Postman. This is the output of the command docker logs dockerdemocontainer

System.Data.SqlClient.SqlException (0x80131904): 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)

I've read about and tried adding network="host" to my docker run command but then I get a 404 when I try to hit localhost:3000, and I don't know how to find where it's running. Not sure whether or not that's a step in the right direction.

What am I missing?

.net
windows
docker
asked on Stack Overflow Dec 31, 2019 by Mike Faber

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0