[root@QK ~]# docker network ls
NETWORK ID NAME DRIVER SCOPE
89de730f6075 bridge bridge local
eb6d94d2bf0a host host local
89204f4ab500 none null local
[root@QK ~]#
2. 网络模式
bridge :桥接 docker(默认)
none :不配置网络
host :和宿主机共享网络
container :容器类网络连通 (局限很大,用的少)
3. 默认的网络模式-bridge
默认隐藏了--net bridge
docker run -d -P --name tomcat02 tomcat
docker run -d -P --name tomcat02 --net bridge tomcat
4. docker network 的所有命令
[root@QK ~]# docker network --help
Usage: docker network COMMAND
Manage networks
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'formore information on a command.
[root@QK ~]#
5. 通过自定义网络实现网络内容器名访问
查看创建自定义网络的相关命令
[root@QK ~]# 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[])
--config-from string The network from which to copy the configuration
--config-only Create a configuration only network
-d, --driver string Driver to manage the Network (default "bridge")
--gateway strings IPv4 or IPv6 Gateway for the master subnet
--ingress Create swarm routing-mesh network
--internal Restrict external access to the network
--ip-range strings 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
-o, --opt map Set driver specific options (default map[])
--scope string Control the network's scope
--subnet strings Subnet in CIDR format that represents a network segment
[root@QK ~]#