[root@docker2 ~]# docker network create --subnet=10.10.10.0/24 docker1 #新键网桥docker1
42323044a4f88a8766d9367e150b9f630cf61f2dd2d9f2d81fad1dc787edac68
[root @ docker2 ~] # ifconfig # ifconfig used to view the card name, found not docker1, but beginning with the string br
br-42323044a4f8: the flags = 4099 <the UP, BROADCAST, the MULTICAST> 1500 MTU
inet 10.10.10.1 Netmask 255.255. Broadcast 0.0.0.0 255.0
ether 02: 42 is: E3: 1F: EB: B6 txqueuelen 0 (Ethernet)
the RX packets bytes 0 0 (0.0 B)
the RX errors Dropped 0 0 0 Frame 0 overruns
the TX packets bytes 0 0 (0.0 B)
the TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
We can change the name of the card through the following steps:
1.[root@docker2 ~]# docker network list
NETWORK ID NAME DRIVER SCOPE
20d5d1508381 bridge bridge local
42323044a4f8 docker1 bridge local
2b94069ca87d host host local
5eccab8d02af none null local
2. Check the system default underlying information docker0 (20d5d1508381) of
[root@docker2 ~]# docker netwrok inspect 20d5d1508381
......
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0", #注意这个命令行
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
3. 删除网桥
[root @ docker2 ~] # Docker Network RM docker1
docker1
4. Re-create the bridge
[root@docker2 ~]# docker network create docker1 -o com.docker.network.bridge.name=docker1
bd9fb699dcda7f2fb8aaa3ed49d63e8ad6ffdbd0146f9fe991b50ecf4a32e8f9
5.使用ifconfig查看,可以看到网卡名称为docker1
[root@docker2 ~]# ifconfig
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:3b:3d:b8:a1 txqueuelen 0 (Ethernet)
RX packets 41 bytes 3113 (3.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 23 bytes 1650 (1.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:cf:ee:d3:6f txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
6. If you want to create a bridge at the time, custom network segment, run the following command:
[root@docker2 ~]# docker network create docker02 --subnet=172.30.0.0/16 -o com.docker.network.bridge.name=docker02
929023f79e25a03ed5fd99150ab354555ce5088bd90f4f1a06ed7a3be4cc4cde
[root@docker2 ~]# ifconfig docker02
docker02: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.30.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:61:44:57:54 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
End.