How to ping individual Container from Windows host?

I have been working with the Docker container for quite some time as I was creating a service that will be running in the image sending messages and recording successful message sent/ any errors if it had failed from the image. This service is the same in both host and container, in addition, in order for the service to work it would require the IP address of the host (for sending/receiving) and container (same).

Host IP address: 192.168.7.20
Container IP address: 192.168.3.2

However, it keeps on failing as I am not receiving any response when sending messages to the container. So, I tried to do the ping command in Command Prompt but kept on getting “Destination host unreachable” as shown below:

ping 192.168.3.2

Pinging 192.168.3.2 with 32 bytes of data:
Reply from 192.168.7.20: Destination host unreachable.
Reply from 192.168.7.20: Destination host unreachable.
Reply from 192.168.7.20: Destination host unreachable.
Reply from 192.168.7.20: Destination host unreachable.

Ping statistics for 192.168.3.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

On the other hand, if I used ping from the container I got a response as shown below:

root@debian:/# ping 192.168.7.20
PING 192.168.7.20 (192.168.7.20) 56(84) bytes of data.
64 bytes from 192.168.7.20: icmp_seq=1 ttl=63 time=26.7 ms
64 bytes from 192.168.7.20: icmp_seq=2 ttl=63 time=1.79 ms
64 bytes from 192.168.7.20: icmp_seq=3 ttl=63 time=2.95 ms
64 bytes from 192.168.7.20: icmp_seq=4 ttl=63 time=2.38 ms
^C
--- 192.168.7.20 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 10ms
rtt min/avg/max/mdev = 1.791/8.449/26.677/10.531 ms

I used the following commands to create the network and run the docker container:

docker network create --driver bridge --subnet 192.168.3.0/24 TestNetwork

docker run -it --cap-add=all --hostname debian --net TestNetwork --name TestImage testimage

So the question is how can I ping from the Windows host to the container? Also, if I have more than one container how can I ping each container separately?

I searched through the Web and found that Docker communicates using the vEthernet, I am not sure if I need to make some changes in the properties or not.

StackOverflow question

the vEthernet uses the following IP address and subnet mask:
IP: 172.27.128.1
mask: 255.255.240.0

Also in the Docker Resources:

I found this,

image

in the settings for Docker-Desktop where it is located in → Resources → Network. When I configured that to run with 192.168.3.0/24, I found out that the images and containers are shown like the image below

I couldn’t follow the whole issue. Have you already solved it? It is not clear what kind of containers you are using. Windows containers or Linux containers? Based on some of your shared commands and prompts it seems you have a Debian host. Maybe WSL2 distro? If that’s the case, your containers are inside a WSL distribution and you can’t access them from the host and you don’t really need t, just forward ports.

Don’t touch that network setting unless the network doesn’t work and changing it is a fix. That subnet is the subnet of the virtual machine which is private inside Docker Desktop. If you change it to an existing Docker network’s subnet, you will just break the network.

Thank you for your reply @rimelek

I am running Linux Containers.

This is from the docker container.

No I didn’t. From the question, I was able to ping the host from the container but not the opposite. How can I enable the host to ping the container?