'How to connect to host machine from a Windows-Container with transparent network driver

I'm using a Windows-Image container with a transparent network driver:

  • Host SO: Windows 10 Pro
  • Container Image: mcr.microsoft.com/dotnet/sdk:5.0-windowsservercore-ltsc2019
C:\>docker version
Client:
 Cloud integration: v1.0.22
 Version:           20.10.13
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 10 14:13:04 2022
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.6.0 (75818)
 Engine:
  Version:          20.10.13
  API version:      1.41 (minimum version 1.24)
  Go version:       go1.16.15
  Git commit:       906f57f
  Built:            Thu Mar 10 14:08:21 2022
  OS/Arch:          windows/amd64
  Experimental:     true

Network used:

docker network create --driver transparent -o com.docker.network.windowsshim.interface="Ethernet 7" --subnet 10.61.1.0/24 --gateway 10.61.1.254 MY_NETWORK

Command to run the container:

docker run --net MY_NETWORK --ip 10.61.1.120 --add-host=host.docker.internal:host-gateway -it --name TEST_1 testimage cmd.exe

I can ping the host from within the container and viceversa.
But when I try to call a service runnig on the host, the 'host.docker.internal' is not resolved:

enter image description here

The host file in the host machine (10.61.1.102) is:

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source