Docker Community Forums

Share and learn in the Docker community.

Problem connecting to Docker SQL Server instance from host machine


(Harneet463) #1

I started a SQL Server 2016 express container and it works like charm.
SQL Server instance is visible and accessible from all the machines except the host machine on which the container is running.
I tried all the combinations of localhost\SQLexpress,1433 using ipaddress etc. but to no avail.
Everything seemed to work fine at the container level as all services were running as viewed with docker exec net start.
And the instance was responsing to all remote machines.
As process of troubleshooting I found out the conatiner IP address and tried connecting to it.
Ola it worked, so I was able to connect to 172.x.x.x\SQLEXPRESS,1433 but not hostname\SQLEXPRESS,1433 or localhost for that matter.

What could be the reason for that, this configuration does not work for me cause the IP address of the container changes whenever it restarts.

Thanks in advance for helping !!


(Michael Friis) #2

I recommend checking out this blog post: https://blog.sixeyed.com/published-ports-on-windows-containers-dont-do-loopback/


(Harneet463) #3

Thanks a lot friism.
:slight_smile: