第 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 为 ...
随机推荐
- Kali linux 2018安装后全屏乱码解决
安装的时候选择了中文, 后来安装成功后成了全部乱码的. 原因是,系统没有中文字体显示安装包, 下载一个 sudo apt-get install ttf-wqy-zenhei 重启解决!
- sentos7为例添加python3和python2共存
转载:https://www.cnblogs.com/JahanGu/p/7452527.html 1.查看是否已经安装Python CentOS 7.2 默认安装了python2.7.5 因为一些命 ...
- py4CV例子1猫狗大战和Knn算法
1.什么是猫狗大战: 数据集来源于Kaggle(一个为开发商和数据科学家提供举办机器学习竞赛.托管数据库.编写和分享代码的平台),原数据集有12500只猫和12500只狗,分为训练.测试两个部分. 2 ...
- linux物理网卡检测命令mii-tool
mii-tool #是用于查看.管理物理的网络接口的状态,还可以配置网卡需要的协商方式. 一 ,查看网卡工作状态 mill-tool [网卡名] #查看物理网卡连接状态 -V 显示版本信息 ...
- SPOJ SUBLEX Lexicographical Substring Search - 后缀数组
题目传送门 传送门I 传送门II 题目大意 给定一个字符串,多次询问它的第$k$大本质不同的子串,输出它. 考虑后缀Trie.依次考虑每个后缀新增的本质不同的子串个数,显然,它是$n - sa[i] ...
- 使用vim打造自己的python编辑器
基础配置 vim的配置是在用户主目录下的 ~/.vimrc 文件中完成的,如果没有的话,需要自己新建一下: cd ~ touch .vimrc 首先做些简单的配置: set nocompatible ...
- java利用poi生成excel文件后下载本地
1.该功能需要poi的jar包,链接: http://pan.baidu.com/s/1migAtNq 密码: 38fx. 2.首先新建一个实体类,用以存放单个数据 public class Test ...
- RabbitMQ 入门指南——初步使用
MQ的消息持久化 https://www.rabbitmq.com/tutorials/tutorial-two-java.html When RabbitMQ quits or crashes it ...
- tp剩余未验证内容-3
为什么有时候会 出现 "上传文件保存错误"? public function save($file, $replace=true){ /* 移动文件 */ if (!move_up ...
- Docker 安装Hadoop HDFS命令行操作
网上拉取Docker模板,使用singlarities/hadoop镜像 [root@localhost /]# docker pull singularities/hadoop 查看: [root@ ...