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.