Unable To Connect To Sql Server From A Docker Container
We have an ASP.NET Core 2.2 application that worked with its backend database hosted on a separate server perfectly. All CRUD operations worked flawlessly. We dockerized the applic
Solution 1:
In a normal situation you could fix by adding the sql hostname in the /etc/hosts file of the container via composer file like this:
version:'3.4'services:services.webapi:image:${DOCKER_REGISTRY-}serviceswebapibuild:context:.dockerfile:Services.WebApi\Dockerfilenetwork:hostextra_hosts:-"WIN_MSSQL1:192.168.0.1"Unfortunately due this issue adding the extra_hosts in the composer file will not work, I hope they fix the issue soon.
So to let connection work substitute the hostname with the ip address of SQL server:
from this:
Server=WIN-MSSQL1\\MSSQLSERVER2017;Initial Catalog=ServiceDB;User ID=cruduser;Password=foo;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=Falseto this:
Server=192.168.0.1\\MSSQLSERVER2017;Initial Catalog=ServiceDB;User ID=cruduser;Password=foo;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
Post a Comment for "Unable To Connect To Sql Server From A Docker Container"