docker network create [参数] network_name
create可选参数
--driver: 指定网络驱动程序,默认是bridge。
--subnet: 指定网络的子网。
--gateway: 指定网络的网关地址。
--ip-range: 指定网络中可用的IP范围。
--ipv6: 启用IPv6支持。
#创建成功后会输出一个uuid
[root@centos ~]# docker network create --subnet 192.168.0.0/24 --gateway 192.168.0.1 my-network
d219aa0580f65e806dc780348bfac2f86b20d205ced04cc573d7407c3d7e0e59
#查看是否创建成功
[root@centos ~]# docker network list
NETWORK ID NAME DRIVER SCOPE
fe81ac498d3a bridge bridge local
1496d86081d1 host host local
d219aa0580f6 my-network bridge local
1b49871e2a02 none null local
#查看网络的详细信息
[root@centos ~]# docker inspect my-network
[
{
"Name": "my-network",
"Id": "d219aa0580f65e806dc780348bfac2f86b20d205ced04cc573d7407c3d7e0e59",
"Created": "2024-04-26T14:08:30.96309215+08:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "192.168.0.0/24",
"Gateway": "192.168.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {},
"Options": {},
"Labels": {}
}
]
[root@centos ~]#