docker容器网络互通

 

https://www.cnblogs.com/sanduzxcvbnm/p/13367071.html

 

一. 让两个不在同一网段的容器网络互通

# 自定义一个网络
docker network create --driver bridge --subnet 192.168.0.0/16 --gateway 192.168.0.1 mynet

#把两个单独的容器加入到此网络
docker network connect mynet nginx-test_nginx_1
docker network connect mynet m3-test-centos

#测试连通性
docker exec -it m3-test-centos ping nginx-test_nginx_1

#查看docker网络
docker network ls
docker network inspect mynet

 

posted @ 2020-11-13 16:15  坚强的小蚂蚁  阅读(406)  评论(0编辑  收藏  举报