I have a Windows 10 laptop running SQL Server and Docker for Windows. I have a linux container running a .NET Core app trying to connect to SQL Server on the laptop. I’ve found that on my work network, I can connect using my machine name. When travelling, I can’t use my machine name and must use the local IP address assigned to me by the network I’m on. It seems that Docker uses 8.8.8.8 for DNS name resolution in these cases. Is there some way to access my laptop by name from within my containers? Why does Docker seem to need a DNS server to resolve the name of the computer it’s running on?
Any help would be appreciated. It’s tiring changing my connection string every day to reflect the IP address of the network I connect to in each city I visit.
Thanks for the reply. In this case, I’m not looking to run SQL Server on Linux, but rather attach to an existing SQL Server on my Windows laptop. More broadly, I’m wondering why I can’t see the Windows machine that’s running Docker from my Docker containers unless I’m on a network with a DNS server that lists my laptop? I realize that the containers will connect via a network connection, but shouldn’t the host machine be a special case that doesn’t require a DNS server? I can now work around it as I move from network to network by obtaining my IP address on each network and reconfiguring my app each time, but this seems to be a pretty common scenario that should be handled. Why should my containers not be able to see my laptop if I happen to be in a Starbucks or a hotel or a lecture hall? I appreciate your reply.
I figured it was that network adapter by looking at the IP range specified for the DockerNAT virtual switch NAT and finding the virtual adapter on my host that had and IP in that range.
I can now ping the same name inside and outside the container.