How to talk to my local VM from windows docker container

I am having trouble to ping my vm from windows docker container, here is my set up.

vm ipconfig

Ethernet adapter Ethernet 8:

   Connection-specific DNS Suffix  . : mshome.net
   Link-local IPv6 Address . . . . . : fe80::7011:8cbe:1c0b:abba%5
   IPv4 Address. . . . . . . . . . . : 172.26.155.70
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . : 172.26.144.1

This is my docker default nat network

docker network inspect nat
[
    {
        "Name": "nat",
        "Id": "a6b61d41933265c941e3f0b1fe3b076651493d8fb686b0b4e3e3a1766f2aff2a",
        "Created": "2024-11-16T10:13:21.9951025+13:00",
        "Scope": "local",
        "Driver": "nat",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "windows",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.30.144.0/20",
                    "Gateway": "172.30.144.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Options": {
            "com.docker.network.windowsshim.hnsid": "7E0ECD2C-54A5-4F3D-BB40-C7B4DAADB159",
            "com.docker.network.windowsshim.networkname": "nat"
        },
        "Labels": {}
    }
]

And I can not ping when I run: (request timed out is the output I got)

docker run `
--name test `
--rm `
--interactive `
--entrypoint powershell.exe `
mcr.microsoft.com/powershell:latest `
ping 172.26.155.70

Can someone help me how to solve this?

I also tried to add a route on my host machine but it didn’t work either, maybe I added with wrong ip address. I want to able to ping my vm from my windows container.

Any help or suggestions please!

Try host.docker.internal

You might also want to check, whether the docker default subnet ranges do not conflict with your companies subnets.

Probably not related in your current situation, but your current ip 172.26.155.70/20 might conflict with the default cidr ranges docker uses for the user defined bridge networks.

You can list the subnets of the docker networks with a command like in this:

docker inspect --format '{{.Name}}:{{(index .IPAM.Config 0).Subnet}}'  $(docker network ls  --filter 'driver=bridge' -q)

This topic might be usefull when you need to change the subnet cidrs: https://forums.docker.com/t/docker-change-default-ip-range-for-all-and-new-containers/144474/8