第 8 章 容器网络 - 055 - 创建 macvlan 网络
1、创建 macvlan 网络
在 host1 和 host2 中创建 macvlan 网络 mac_net1:
docker network create -d macvlan --subnet=172.16.86.0/24 --gateway=172.16.86.1 -o parent=ens192 mac_net1

注意:在 host2 中也要执行相同的命令。
1) -d macvlan 指定 driver 为 macvlan。
2) macvlan 网络是 local 网络,为了保证跨主机能够通信,用户需要自己管理 IP subnet。
3) 与其他网络不同,docker 不会为 macvlan 创建网关,这里的网关应该是真实存在的,否则容器无法路由。
4) -o parent 指定使用的网络 interface。
在 host1 中运行容器 bbox1 并连接到 mac_net1。
由于 host1 中的 mac_net1 与 host2 中的 mac_net1 本质上是独立的,为了避免自动分配造成 IP 冲突,我们最好通过 --ip 指定 bbox1 地址为 172.16.86.10。
docker run -itd --name bbox1 --ip=172.16.86.10 --network mac_net1 busybox 
在 host2 中运行容器 bbox2,指定 IP 172.16.86.11。
docker run -itd --name bbox2 --ip=172.16.86.11 --network mac_net1 busybox

验证 bbox1 和 bbox1 的连通性。

bbox2 能够 ping 到 bbox1 的 IP 172.16.86.10,但无法解析 “bbox1” 主机名。

可见 docker 没有为 macvlan 提供 DNS 服务,这点与 overlay 网络是不同的。
-----------------------------------------引用来自---------------------------------------------------
https://mp.weixin.qq.com/s?__biz=MzIwMTM5MjUwMg==&mid=2653587785&idx=1&sn=f04daf7ceb281fce4bcc7e7d45d1255d&chksm=8d308150ba470846d9c9c927f035ef296375791f553c54891fbc9ea486ae5e0958c513dbc272&scene=21#wechat_redirect
第 8 章 容器网络 - 055 - 创建 macvlan 网络的更多相关文章
- 创建 macvlan 网络 - 每天5分钟玩转 Docker 容器技术(55)
上一节我们准备好了 macvlan 的实验环境,今天在 host1 和 host2 中创建 macvlan 网络 mac_net1: 注意:在 host2 中也要执行相同的命令. ① -d macvl ...
- 055、创建macvlan网络 (2019-03-22 周五)
参考https://www.cnblogs.com/CloudMan6/p/7364332.html 创建macvlan网络,需要指定使用哪块物理网卡进行通信 -o parent=ens1 ...
- 第 8 章 容器网络 - 050 - 创建 overlay 网络
在 host1 中创建 overlay 网络 ov_net1: docker network create -d overlay ov_net1 -d overlay 指定 driver 为 over ...
- 第 8 章 容器网络 - 056 - macvlan 网络结构分析
macvlan 网络结构分析 macvlan 不依赖 Linux bridge,brctl show 可以确认没有创建新的 bridge. 查看一下容器 bbox1 的网络设备: 除了 lo,容器只有 ...
- macvlan 网络结构分析 - 每天5分钟玩转 Docker 容器技术(56)
上一节我们创建了 macvlan 并部署了容器,本节详细分析 macvlan 底层网络结构. macvlan 网络结构分析 macvlan 不依赖 Linux bridge,brctl show 可以 ...
- 第 8 章 容器网络 - 054 - 准备 macvlan 环境
准备 macvlan 环境 macvlan 本身是 linux kernel 模块,其功能是允许在同一个物理网卡上配置多个 MAC 地址,即多个 interface,每个 interface 可以配置 ...
- 第 8 章 容器网络 - 057 - macvlan 网络隔离和连通
macvlan 网络隔离和连通 验证 macvlan 之间的连通性. bbox1 能 ping 通 bbox3,bbox2 能 ping 通 bbox4. 即:同一 macvlan 网络能通信. bb ...
- macvlan 网络隔离和连通 - 每天5分钟玩转 Docker 容器技术(57)
上一节我们创建了两个 macvlan 并部署了容器,网络结构如下: 本节验证 macvlan 之间的连通性. bbox1 能 ping 通 bbox3,bbox2 能 ping 通 bbox4.即:同 ...
- 创建 overlay 网络 - 每天5分钟玩转 Docker 容器技术(50)
上一节我们搭建好实验环境,配置并运行了consul,今天开始创建 overlay 网络. 在 host1 中创建 overlay 网络 ov_net1: -d overlay 指定 driver 为 ...
随机推荐
- phpstorm 配置点右上角浏览器图标时用浏览器打开当前页面
文件>设置 只要这一步就可以这样了
- FBX SDK在vs 2010下面的配置
1.下载FBS SDK.地址.因为我是vs2010,所以我下载的是FBX SDK 2016.1.2 VS2010.如果没有了,你可以找博主直接要,QQ1240957820. 2.下载下来的是一个exe ...
- 做了一道cf水题
被一道cf水题卡了半天的时间,主要原因时自己不熟悉c++stl库的函数,本来一个可以用库解决的问题,我用c语言模拟了那个函数半天,结果还超时了. 题意大概就是,给定n个数,查询k次,每次查询过后,输出 ...
- 在vim中 安装php的xdebug和 vdebug插件, 在vim中进行调试php代码
在vim中 安装php的xdebug和 vdebug插件, 在vim中进行调试php代码 参考: http://www.cnblogs.com/qiantuwuliang/archive/2011/0 ...
- EXCEL 基本函数
案例2:修改非法日期 TODAY(),显示今天日期,数据格式是日期,如果是常规,就是数字. EXCEL 起始日期,1900/1/1是第一天 日期输入方式要正确 时间数据格式 1:00:00 = 1 ...
- ZOJ 4027 Sequence Swapping(DP)题解
题意:一串括号,每个括号代表一个值,当有相邻括号组成()时,可以交换他们两个并得到他们值的乘积,问你最大能得到多少 思路:DP题,注定想得掉头发. 显然一个左括号( 的最远交换距离由他右边的左括号的最 ...
- Run tomcat on port 80 not 8080
How to run Tomcat on Port 80 A standard Tomcat installation starts the webserver on port 8080 – whic ...
- p4168 [Violet]蒲公英(分块)
区间众数的重题 和数列分块入门9双倍经验还是挺好的 然后开O2水过 好像有不带log的写法啊 之后在补就是咕咕咕 // luogu-judger-enable-o2 #include <cstd ...
- 给Ubuntu添加清华的软件源
找到 sources.list 文件 cd /etc/apt/ 编辑 vim sources.list 在最后面加上下面这几条语句 # 默认注释了源码镜像以提高 apt update 速度,如有需要可 ...
- javascript创建函数的20种方式汇总
http://www.jb51.net/article/68285.htm 工作中常常会创建一个函数来解决一些需求问题,以下是个人在工作中总结出来的创建函数20种方式,你知道多少? function ...