Docker container intercommunication port scenario test

Docker container intercommunication port scenario test

 

172.26.11.221 > Container 1

172.26.11.222 

 

Scenario 1: By executing the command nc -l 1234 at 172.26.11.222, then nc 172.26.11.222 1234 in container 1

 

Then execute netstat -nlap in container 1

show:

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp        0      0 172.17.0.2:47014            172.26.11.222:1234          ESTABLISHED 525/nc   

 

Then execute the command on 172.26.11.221 on the host of container 1: netstat -nlap|grep 47014 is empty

 

Then execute the command netstat -nlap|grep 47014 on 172.26.11.222

 

tcp        0      0 172.26.11.222:1234      172.26.11.221:47014     ESTABLISHED 6008/nc 

 

Port 47014 corresponds to port 172.26.11.221, but there is no port 47014 when viewed on 172.26.11.221

 

Summarize:

When container 1 and 172.26.11.222 establish tcp communication, container 1 starts port 47014 internally, and has a port mapping with the host 172.26.11.221, and establishes tcp connection communication with the outside through this mapping relationship

 

 

Scenario 2: Container 1 starts the dubbo service, registers it in zk, and displays the container's ip and port number on the zk console (according to scenario 1, the connection to zk is now the container 1 host 172.26.11.221)

In the scenario of dubbo, the docker container network is no problem

View client connection information by echo cons | nc 127.0.0.1 2181

 /172.26.11.224:46552[1](queued=0,recved=2,sent=2,sid=0x158eb8f374d0004,lop=PING,est=1481426888544,to=30000,lcxid=0x0,lzxid=0xa,lresp=1481426898571,llat=0,minlat=0,avglat=25,maxlat=50)

 /127.0.0.1:39315[0](queued=0,recved=1,sent=0)

 /172.26.11.224:60971[1](queued=0,recved=553,sent=553,sid=0x158eb8f374d0001,lop=PING,est=1481421373591,to=30000,lcxid=0x0,lzxid=0xa,lresp=1481426897377,llat=0,minlat=0,avglat=0,maxlat=17)

 Even if it is connected inside the container, the ip of the container host is displayed.

 

 

Scenario 3: External access to the container http service, only communication between containers can be achieved through docker native container communication, the container accesses the host, but the host cannot access the container

Change a docker network communication mode flannel

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326799771&siteId=291194637