1yuminstalldocker-ce-yyuminstallpython-pip-ypipinstalldocker-composesystemctlenabledocker.servicesystemctlstartdocker.servicedockerpullprogrium/consul环境:192.168.56.11192.168.56.12192.168.56.13目的实现192.168.56.11自建网络互通192.168.56.13dockerrun-d-p8500:8500--nameconsulprogrium/consul-server-bootstrap192.168.56.11/usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/dockerd-Htcp://192.168.56.11-Hunix://var/run/docker.sock[root@linux-node1~]#cat/etc/docker/daemon.json{"registry-mirrors":["http://224ac393.m.daocloud.io"],"cluster-store":"consul://192.168.56.13:8500","cluster-advertise":"192.168.56.11:2375"}[root@linux-node1~]#systemctldaemon-reloadsystemctlrestartdocker192.168.56.12/usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/dockerd-Htcp://192.168.56.12-Hunix://var/run/docker.sock[root@linux-node1~]#cat/etc/docker/daemon.json{"registry-mirrors":["http://224ac393.m.daocloud.io"],"cluster-store":"consul://192.168.56.13:8500","cluster-advertise":"192.168.56.12:2375"}[root@linux-node2~]#systemctldaemon-reloadsystemctlrestartdocker浏览器浏览测试192.168.56.11上面dockernetworkcreate-doverlay--subnet192.168.1.0/24ov_net1#192.168.56.12上面默认就有了不用创建了[root@linux-node1~]#dockernetworklsNETWORKIDNAMEDRIVERSCOPE587ebbdc8cf6bridgebridgelocal42863825595adocker_gwbridgebridgelocaldf6484f00517hosthostlocaladf74519830enonenulllocale8d259aa8fe3ov_net1overlayglobal[root@linux-node1~]#[root@linux-node2~]#dockernetworklsNETWORKIDNAMEDRIVERSCOPE624c4d1628bdbridgebridgelocal4f7d45ab8d94docker_gwbridgebridgelocaldf6484f00517hosthostlocaladf74519830enonenulllocale8d259aa8fe3ov_net1overlayglobal[root@linux-node2~]#192.168.56.11测试dockerrun-it--rm--net=ov_net1busybox192.168.56.12测试dockerrun-it--rm--net=ov_net1busybox查看两个容器的IP地址互相ping下可以ping通dockerrun-it--rm--net=ov_net1--ip=192.168.1.10busybox#指定IP地址
300字范文,内容丰富有趣,生活中的好帮手!