第 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 为 ...
随机推荐
- runtime.Gosched()的作用分析
untime.Gosched()用于让出CPU时间片.这就像跑接力赛,A跑了一会碰到代码runtime.Gosched()就把接力棒交给B了,A歇着了,B继续跑 测试代码: package main ...
- 11: python中的轻量级定时任务调度库:schedule
1.1 schedule 基本使用 1.schedule 介绍 1. 提到定时任务调度的时候,相信很多人会想到芹菜celery,要么就写个脚本塞到crontab中. 2. 不过,一个小的定时脚本,要用 ...
- 03: pip使用
1.1 pip常用方法 1.自我升级(升级pip到最新版本) pip install --upgrade pip 2. 安装库 pip install XXX 3. 查看当前环境所有已安装的库 pip ...
- echarts自定义图例legend文字和样式
话不多说,先上效果图. 要完成这个图并不难,主要是下面那个图例比较难,需要定制. 让我们从官方文档找找思路,官方文档关于legend.formatter是这样的:链接在这 难点在于: 1.这里的图例文 ...
- bzoj 4585 烟火表演 - 动态规划 - 可并堆
题目传送门 传送门I 传送门II 题目大意 给定一棵带边权有根树,修改一条边的边权的代价是修改前和修改后的值的绝对值之差.不能将一条边的边权改为负数.问使得根节点到所有叶节点的距离相等的最小代价. 当 ...
- vS+QT生成.pro文件
- CentOS7搭建jdk
背景 现在很多Linux系统在安装完成时就自带jdk,但是系统自带的jdk有时候并不符合我们的需求,这时候我们需要自己来安装jdk. 步骤 下载jdk,我下载的是64位的jdk-8u161-linux ...
- Hakase and Nano 【思维博弈】
Hakase and Nano 时间限制: 1 Sec 内存限制: 128 MB 提交: 400 解决: 104 [提交] [状态] [命题人:admin] 题目描述 Hakase and Nan ...
- C# 基于任务的异步模式的创建与使用的简单示例
对于窗体程序,使用基于任务的异步模式需要用到Task类,下面示例下非常简单的用法. 1.创建一个拥有异步方法的类 该类拥有一个异步方法DoSomthingAsync,根据微软建议的命名规则该方法要带A ...
- 查找第K大的数
类快排 第一种方法 o(n) #include <bits/stdc++.h> using namespace std; const int N = 1000; int s[N]; int ...