2台宿主机,hslave1 192.168.1.153, hslave2 192.168.1.154

 

修改网段


 docker0默认网段是172.17.0.0/16,修改154机器的docker0的网段

 

vi /usr/lib/systemd/system/docker.service

#修改下面这行

ExecStart=/usr/bin/docker daemon --bip=172.18.42.1/16 -H fd:// -H=unix:///var/run/docker.sock

 

重启Docker

systemctl stop docker

systemctl start docker

 

修改宿主机路由 


153

route add -net 172.18.0.0/16 gw 192.168.1.154

154

route add -net 172.17.0.0/16 gw 192.168.1.153

 

这里添加的路由规则在宿主机重启后,会消失。

Docker contanier comunication with route

 

 

Docker contanier comunication with route

 

启动容器互联


 154容器连接153MYSQL

Docker contanier comunication with route

 

153连接154MYSQL

Docker contanier comunication with route

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2022-02-15
  • 2022-02-24
猜你喜欢
  • 2021-12-22
  • 2021-10-19
  • 2021-06-22
  • 2021-05-14
  • 2022-01-23
  • 2021-09-13
  • 2022-01-05
相关资源
相似解决方案