[root@docker ~]# docker network ls NETWORK ID NAME DRIVER SCOPE 5133ec415c3c bridge bridge local f359ca4e2d39 host host local 8d68673c045c none null local
创建网络
现在创建一个网络名为my_net且driver为bridge的网络:(默认创建的就是bridge)
1 2 3 4 5 6 7 8 9 10
[root@docker ~]# docker network create my_net 67e29f0e4a77c79144efc337a081a889188b5b8e289968f22be6e4ddd9b80610 [root@docker ~]# docker network ls NETWORK ID NAME DRIVER SCOPE 5133ec415c3c bridge bridge local f359ca4e2d39 host host local 67e29f0e4a77 my_net bridge local 8d68673c045c none null local #创建network,指定网段 [root@docker ~]# docker network create --driver bridge --subnet=172.21.0.0/16 my-network01
[root@]# docker network --help Usage: docker network COMMAND Manage networks Options: --help Print usage Commands: connect Connect a container to a network create Create a network disconnect Disconnect a container from a network inspect Display detailed information on one or more networks ls List networks prune Remove all unused networks rm Remove one or more networks Run 'docker network COMMAND --help' for more information on a command.
docker network command –help 查看具体命令的详细参数和用法
1 2 3 4 5 6 7 8 9 10 11 12 13
[root@]# docker network connect --help Usage: docker network connect [OPTIONS] NETWORK CONTAINER Connect a container to a network Options: --alias stringSlice Add network-scoped alias for the container --help Print usage --ip string IP Address --ip6 string IPv6 Address --link list Add link to another container (default []) --link-local-ip stringSlice Add a link-local address for the container
[root@izwz9fnxall7j07rfgkvwqz seafile]# docker network create --help Usage: docker network create [OPTIONS] NETWORK Create a network Options: --attachable Enable manual container attachment # 允许手动附加到容器 --aux-address map Auxiliary IPv4 or IPv6 addresses used by Network driver (default map[]) -d, --driver string Driver to manage the Network (default "bridge") --gateway stringSlice IPv4 or IPv6 Gateway for the master subnet --help Print usage --internal Restrict external access to the network --ip-range stringSlice Allocate container ip from a sub-range --ipam-driver string IP Address Management Driver (default "default") --ipam-opt map Set IPAM driver specific options (default map[]) --ipv6 Enable IPv6 networking --label list Set metadata on a network (default []) -o, --opt map Set driver specific options (default map[]) --subnet stringSlice Subnet in CIDR format that represents a segment
比如 docker network create lzwj 网络默认采用桥接网络 docker network ls [root@seafile]# docker network ls NETWORK ID NAME DRIVER SCOPE 62180a9e2a6f bridge bridge local d80fef8de8ba host host local 6a5ad5bc599c lzwj bridge local