Docker Community Forums

Share and learn in the Docker community.

SQL Connection to local instance failed

Created an ASP.Net Core WebApi project, added a Controller that using GET tries to do a simple request to a (local) host Window SQL Server instance. Debug the service and works fine, but not in a docker container with the following exception message:

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: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

Went through all existing forums posted with similar issues, follow samples and recommendations and still have the issue.

Some details:

  • The connection string: Server=192.168.1.XX,1433;Database=SOMEDB; User ID=someuser;Password=somepassword;
  • Opened the 1433 port in firewall;
  • Tested the connection string params in the Management Studio successfully;

The exercise is hands-down simple and should work according to recommendations. What I may be missing?