Relative Content

Tag Archive for .netdatabasedockernetworkingdns

Docker container hostname resolving not working in .net

I have docker file that runs dotnet test before publishing. Some of the tests are integration tests that require a real database. For that i start a sql server docker container before docker build. I created a custom docker network for the both of them to work on and when i telnet or ping from the container that is building my container to my sql server container that works perfectly, using both the sql server container name and it’s ip address. But using the same hostname in the connectionstring of my .net 8 ef core app it throws an exception. Using the ip address of my sql server container which i get from docker network inspection it works just fine. So somehow .net 8 is not able to resolve the sql server container name to it’s ip address. Btw calling Dns.GetHostAddresses from the .net app results in a similar exception.