I have a host (Ubuntu), a docker container (centOS), a virtual machine (centOS).
- My Host has 2 interfaces, one is eth0 "192.168.0.4", one is docker0 "172.17.42.1"
- My docker container have IP "172.17.0.1". It has a service bind on port 80.
- On Virtual Machine, I use bridge adapter with docker0 and I config "/etc/sysconfig/network-scripts/ifcfg-eth0" file like this:
DEVICE="eth0" ONBOOT=yes HWADDR=08:00:27:72:40:6B TYPE=Ethernet BOOTPROTO=static IPADDR=172.17.0.250 NETMASK=255.255.0.0
From host, I telnet to container's service
$ telnet 172.17.0.1 80 Trying 172.17.0.1... Connected to 172.17.0.1. Escape character is '^]'.
It is OK!
BUT, From Virtual Machine I cannot telnet to it
$ telnet 172.17.0.1 80 Trying 172.17.0.1... telnet: Unable to connect to remote host: Connection timed out
From my Virtual Machine, I can ping the Docker Container
$ ping 172.17.0.1 PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data. 64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.091 ms
So, How to telnet to my service on Docker Container?