Several basic methods of Docker container interconnection

 

(1) The container mounts the host directory: -v --volumes-from

(2) Interconnection between containers: –link

(3) External access to the container: -p

(4) Use the host network directly

  docker run --rm=true --net=host --name=mydb -e MYSQL_ROOT_PASSWORD=123456 mysql

  # Use the following command to check that the container IP is exactly the same as the host

  docker exec -it mydb ip addr

 

(5) Containers share an IP network

  docker run --rm=true --name=mydb -e MYSQL_ROOT_PASSWORD=123456 mysql

# Create a new container and specify a shared IP with the existing container

  docker run --rm=true --net=container:mydb java ip addr

 

  

Which Docker container cross-host communication scheme should I choose?

My environment is that Docker is installed in the virtual machines on 5 physical hosts, each of which has 3 containers. Now to solve the cross-host communication of containers, there are five solutions collected on the Internet:

1. Using OpenVSwitch

2. Use Weave

3. Overlay network supported by Docker after 1.9 (this seems to be the official practice)

Docker 1.9 Overlay Network realizes cross-host network interworking

4. Group containers of multiple physical machines into a physical network to

1. Create your own bridge br0

2. Bind the docker default bridge to br0

Container interconnection between multiple physical hosts

5. Modify the default virtual network segment of the host docker, and then add the other party's docker network segment to the routing table on each host, and cooperate with iptables to realize cross-host communication between docker containers

How to make docker containers on different hosts communicate with each other

 

 

http://m.blog.csdn.net/article/details?id=51627803

https://www.zhihu.com/question/49245479

Guess you like

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