How to achieve communication problems between Docker containers across hosts

Here the most original bridge mode to achieve the host direct cross-Docker container communication problems.

Some commonly used commands

    brctl show br0
    brctl addbr br0
    brctl addif br0 eth0
    ifconfig br0 down

1. Install brctl Kit

apt-get install bridge-utils

2. Create a docker bridge network type (ip hosts to fill in and the same ip)

docker network create --subnet=192.168.17.100/16 br0

Here is my host ip 192.168.17.9 ip gateway 192.168.17.254 docker's needs is the same network segment 192.168.17. *

3. The use of docker bridge tool mounted to the bridge card host

eth0 the addif BR0 brctl
brctl the addif BR0 (Docker bridge) eth0 (host NIC)

4. Set the docker card ip

ifconfig br0 192.168.17.100 up

5. Start the container need to specify in advance ip

sudo docker run -it  -h test --privileged=True --net=staticnet --ip 192.168.17.101 --name="docker1" -p 1111:80 -p 1112:8080 ambari:v1.0 /bin/bash

6. The above operation is performed on another machine, not conflict noted ip

Another docker 7. In docker in ping across hosts, if ping through

problem solved.

docker basic commands

docker exec -it ambari-server bash
docker cp /etc/apt/sources.list ambari-server:/etc/apt/
docker export -o ambari-server.tar e932da0e4b3e
docker import ambari-server.tar  ambar:v1
docker run -it --name a ambar:v1 /bin/bash

Guess you like

Origin www.linuxidc.com/Linux/2019-12/161856.htm