Docker Windows container can’t resolve host.docker.internal

My windows docker container cannot resolve host.docker.internal, but it’s working with Linux containers. I would prefer to stay with Linux containers, but I am having trouble with an old .Net framework 4.7.2 application.

My application connects to RabbitMQ on the local machine. This works as expected in the Linux containers, but with the windows container it throws this error:

System.Net.Sockets.SocketException: No such host is known

I’ve tried pinging host.docker.internal.

C:app>ping host.docker.internal  
Ping request could not find host host.docker.internal. Please check the name and try again.

Here is my dockerFile:

FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
ARG source
WORKDIR /app
COPY ${source:-SampleApp/obj/Docker/publish} .
ENTRYPOINT ["C:appSampleApp.exe"]

I’ve also trie

Source: Docker Questions

LEAVE A COMMENT