Docker network网络命令 新增删除查看Docker网络 将正在运行的容器连接到网络 断开容器网络连接
1、docker network create
创建新的Docker网络
语法:
docker network create [OPTIONS] NETWORK
示例:
docker network create my_net
docker network create –driver bridge –subnet 172.30.1.0/24 –gateway 172.30.1.1 my_net
2、docker network rm
删除一个或多个Docker网络
语法:
docker network rm NETWORK [NETWORK…]
示例:
docker network rm my_net
docker network rm 2a7ec206c4ef
3、docker network prune
删除所有未使用的Docker网络
语法:
docker network prune [OPTIONS]
示例:
docker network prune
docker network prune -f
4、docker network ls
查看所有Docker网络
语法:
docker network ls [OPTIONS]
示例:
docker network ls
docker network ls –no-trunc
5、docker network inspect
显示一个或多个Docker网络的详细信息
语法:
docker network inspect [OPTIONS] NETWORK [NETWORK…]
示例:
docker network inspect my_net
docker network inspect 6dedababaa65
6、docker network connect
将容器连接到网络
语法:
docker network connect [OPTIONS] NETWORK CONTAINER
示例:
docker network connect my_net my_container
7、docker network disconnect
断开容器的网络
语法:
docker network disconnect [OPTIONS] NETWORK CONTAINER
示例:
docker network disconnect my_net my_container