docker 实战---多台物理主机的联网,容器桥接到物理网络

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker 实战---多台物理主机的联网,容器桥接到物理网络相关的知识,希望对你有一定的参考价值。

docker 默认的桥接网卡是docker0

它只会在本机桥接所有的容器网卡,举例来说容器的虚拟网卡在主机上看一般叫做veth***  而docker只是把所有这些网卡桥接在一起,如veth2a4c51b:

[[email protected] ~]# brctl show

bridge name   bridge id           STP enabled     interfaces

br0        8000.0050562539b9      no          ens33

[[email protected] ~]# systemctl start dockeer

Failed to start dockeer.service: Unit not found.

[[email protected] ~]# systemctl start docker

[[email protected] ~]# brctl show

bridge name     bridge id            STP enabled     interfaces

br0           8000.0050562539b9       no           ens33

docker0        8000.02427091b8df       no

[[email protected] ~]# docker ps -a

CONTAINER ID    IMAGE         COMMAND       CREATED      STATUS              PORTS                     NAMES

6ceaacf4f8d6  registry   "/entrypoint.sh /etc/"   2 weeks ago  Exited (1) 8 days ago   0.0.0.0:5000->5000/tcp       backstabbing_mclean

[[email protected] ~]# docker start 6ceaacf4f8d6 

6ceaacf4f8d6

[[email protected] ~]# brctl show

bridge name     bridge id          STP enabled     interfaces

br0          8000.0050562539b9       no          ens33

docker0        8000.02427091b8df      no          veth2a4c51b

[[email protected] ~]# ip a s

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

       valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000

    link/ether 00:50:56:25:39:b9 brd ff:ff:ff:ff:ff:ff

    inet6 fe80::250:56ff:fe25:39b9/64 scope link 

       valid_lft forever preferred_lft forever

5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000

    link/ether 00:50:56:25:39:b9 brd ff:ff:ff:ff:ff:ff

    inet 10.0.0.10/24 brd 10.0.0.255 scope global br0

       valid_lft forever preferred_lft forever

    inet6 fe80::250:56ff:fe25:39b9/64 scope link 

       valid_lft forever preferred_lft forever

6: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 

    link/ether 02:42:70:91:b8:df brd ff:ff:ff:ff:ff:ff

    inet 172.17.0.1/16 scope global docker0

       valid_lft forever preferred_lft forever

    inet6 fe80::42:70ff:fe91:b8df/64 scope link 

       valid_lft forever preferred_lft forever

8: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP 

    link/ether 72:b4:21:83:04:b4 brd ff:ff:ff:ff:ff:ff link-netnsid 0

    inet6 fe80::70b4:21ff:fe83:4b4/64 scope link 

       valid_lft forever preferred_lft forever





以上是关于docker 实战---多台物理主机的联网,容器桥接到物理网络的主要内容,如果未能解决你的问题,请参考以下文章

吴裕雄--天生自然 HADOOP大数据分布式处理:CenterOS 7 多台物理机虚拟机相互桥连接ping通,并且能够成功连接外网

centos7 docker宿主机配置桥接物理网络终极实战

如何解决docker宿主机无法访问容器中的服务

VMware 克隆多台Linux机器并配置IP的方法

使用pipework将Docker容器桥接到本地网络环境中

docker技术剖析--docker网络docker宿主机之间容器互通