1.查看網卡信息
ifconfig

2.在docker的centos7命令行中進行eth0設置
設置eth0網卡:vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 NAME="eth0" BRIDGE=br0 BOOTPROTO=dhcp NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet IPV4_FAILURE_FATAL=yes IPV6INIT=no USERCTL=no
3.新建網橋br0的配置(ip自定義的,不必糾結.網關是docker的網關)
設置br0網橋:vi /etc/sysconfig/network-scripts/ifcfg-br0 DEVICE="br0" TYPE="Bridge" NOBOOT="yes" BOOTPROTO="static" IPADDR="172.17.0.1" NETMASK="255.255.255.0" GATEWAY="172.17.42.1" DNS1="202.106.46.151" DNS2="202.106.195.68" DELAY="0"
4.在宿主機上重啟容器,使網橋配置生效
docker restart centos-vnc
5.重新進入容器
docer exec -it centos-vnc /bin/bash
6.查看網絡
ifconfig

7.網橋br0添加eth0端口
brctl show brctl addif br0 eth0 ifconfig eth0 0.0.0.0
8.Ping網絡是否暢通
ping www.baidu.com
