# docker-topo
Docker network topology builder
[![Build Status](https://travis-ci.org/networkop/docker-topo.svg)](https://travis-ci.org/networkop/docker-topo)
# Supported images
* Arista cEOS-lab
* Arista vEOS-lab
* Arista CVP
* All [vrnetlab images][vrnetlab] - experimental support, currently only tested with CSR1k, vMX and XRv.
* User-defined docker images
# Installation
With Python virtualenv (recommended)
```bash
python3 -m pip install virtualenv
python3 -m virtualenv testdir; cd testdir
source bin/activate
pip install git+https://github.com/networkop/docker-topo.git
```
Without virtualenv
````bash
python3 -m pip install --upgrade --user git+https://github.com/networkop/docker-topo.git
````
> Note: Python 2.x is not supported
# Usage
```bash
# docker-topo -h
usage: docker-topo [-h] [-d] [--create | --destroy] [-s] [-a] topology
Tool to create cEOS topologies
positional arguments:
topology Topology file
optional arguments:
-h, --help show this help message and exit
-d, --debug Enable Debug
Actions:
Create or destroy topology
--create Create topology
--destroy Destroy topology
Save:
Save or archive the topology
-s, --save Save topology configs
-a, --archive Archive topology file and configs
```
# Topology file
Topology file is a YAML file describing how docker containers are to be interconnected.
This information is stored in the `links` variable which
contains a list of links. Each link is described by a unique set of connected interfaces.
There are several versions of topology file formats.
## Topology file v1
This version is considered legacy and is documented [here](https://github.com/networkop/docker-topo-topo/blob/master/v1.md).
## Topology file v2
Each link in a `links` array is a dictionary with the following format:
```yaml
VERSION: 2
links:
- endpoints:
- "Device-A:Interface-2"
- "Device-B:Interface-1"
- driver: macvlan
driver_opts:
parent: wlp58s0
endpoints: ["Device-A:Interface-1", "Device-B:Interface-2"]
```
Each link dictionary supports the following elements:
* **endpoints** - the only mandatory element, contains a list of endpoints to be connected to a link.
* **driver** - defines the link driver to be used. Currently supported drivers are **veth, bridge, macvlan**. When driver is not specified, default **bridge** driver is used. The following limitations apply:
* **macvlan** driver will require a mandatory **driver_opts** object described below
* **veth** driver is talking directly to netlink (no libnetwork involved) and making changes to namespaces
* **driver_opts** - optional object containing driver options as required by Docker's libnetwork. Currently only used for macvlan's parent interface definition
Each link endpoint is encoded as "DeviceName:InterfaceName:IPPrefix" with the following contraints:
* **DeviceName** determines which docker image is going to be used by (case-insensitive) matching of the following strings:
* **host** - [alpine-host][alpine-host] image is going to be used
* **cvp** - [cvp](https://github.com/networkop/docker-topo/tree/master/topo-extra-files/cvp) image is going to be used
* **veos** - Arista vEOS image built according to the procedure described [here](https://github.com/networkop/docker-topo/blob/master/topo-extra-files/veos/README.md)
* **vmx** - Juniper vMX image built with [vrnetlab][vrnetlab]
* **csr** - Cisco CSR1000v image built with [vrnetlab][vrnetlab]
* **xrv** - Cisco IOS XRv image built with [vrnetlab][vrnetlab]
* For anything else Arista cEOS image will be used
* **InterfaceName** must match the exact name of the interface you expect to see inside a container. For example if you expect to connect a link to DeviceA interface eth0, endpoint definition should be "DeviceA:eth0"
* **IPPrefix** - Optional parameter that works **ONLY** for [alpine-host][alpine-host] devices and will attempt to configure a provided IP prefix inside a container.
## Bridge vs veth driver caveats
Both bridge and veth driver have their own set of caveats. Keep them in mind when choosing a driver:
| Features | bridge | veth |
|--------|------|------|
| multipoint links | supported | not supported |
| sudo privileges | not required | required |
| docker modifications | requires [patched][1] docker deamon | uses standard docker daemon |
| L2 multicast | only LLDP | supported |
You can mix both **bridge** and **veth** drivers in the same topology, however make sure that **bridge** driver links always come first, followed by the **veth** links. For example:
```
VERSION: 2
driver: veth
links:
- endpoints: ["Leaf1:eth1", "Leaf2:eth1"]
driver: 'bridge'
- endpoints: ["Leaf1:eth2", "Leaf2:eth2"]
- endpoints: ["Leaf1:eth3", "Leaf2:eth3"]
```
__Note__: You also need to specify the default eth0 intefaces for all endpoints given docker-topo does not create said interface whereas normal docker create does create this interface without defining.
## macOS / OSX Support
Pyroute2 supports BSD as of 0.5.2, but veth drivers will not work in topology files.
>Pyroute2 runs natively on Linux and emulates some limited subset of RTNL netlink API on BSD systems on top of PF_ROUTE notifications and standard system tools.
## (Optional) Global variables
Along with the mandatory `link` array, there are a number of options that can be specified to override some of the default settings. Below are the list of options with their default values:
```yaml
VERSION: 1 # Topology file version. Accepts [1|2]
CEOS_IMAGE: ceos:latest # cEOS docker image name
CONF_DIR: './config' # Config directory to store cEOS startup configuration files
PUBLISH_BASE: 8000 # Publish cEOS ports starting from this number
OOB_PREFIX: '192.168.100.0/24' # Only used when link contains CVP. This prefix is assinged to CVP's eth1
PREFIX: 'CEOS-LAB' # This will default to a topology filename (without .yml extension)
driver: None
```
All of the capitalised global variables can also be provided as environment variables with the following priority:
1. Global variables defined in a topology file
2. Global variables from environment variables
3. Defaults
The final **driver** variable can be used to specify the default link driver for **ALL** links at once. This can be used to create all links with non-default **veth** type drivers:
```yaml
VERSION: 2
driver: veth
links:
- endpoints: ["host1:eth1", "host2:eth1"]
- endpoints: ["host1:eth2", "host3:eth1"]
```
There should be several examples in the `./topo-extra-files/examples` directory
## (Optional) Exposing arbitrary ports
By default, `PUBLISH_BASE` will expose internal HTTPS (443/tcp) port of a container. It is possible to expose any number of internal ports for each container by defining `PUBLISH_BASE` in the following way:
```yaml
PUBLISH_BASE:
443/tcp: None # Will expose inside 443 to a random outside port
22/tcp: 2000 # All containers will get their ports exposed starting from outside port 2000
161/tcp: [127.0.0.1, 1600] # Similar to the above but only exposes ports on the defined local IP address
```
**Note:** topology file must have at least one interface of type **bridge** in order for PUBLISH_BASE to work.
## (Optional) Saving and archiving network topologies
By default, `docker-topo` will pick up any files located in the `CONF_DIR` and, if the filename matches the `PREFIX_DEVICENAME`, will mount it inside the container as `/mnt/flash/startup-config`.
When the topology is running, there's a way to easily save the output of "show run" from each device inside the `CONF_DIR` to make them available on next reboot:
```
$ docker-topo -s topology.yml
Config directory exists, existing files may be overwritten. Continue? [y/n]:y
INFO:__main__:All configs saved in ./config
```
Archive option creates a `tar.gz` file with the `CONF_DIR` directory and the topology YAML file
```
$ docker-topo -a topology.yml
INFO:__main__:Archive file topo.tar.gz created
$
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
用于网络模拟的Docker拓扑构建器___下载.zip (76个子文件)
docker-topo-master
.travis.yml 600B
setup.py 704B
LICENSE 1KB
v1.yml 1KB
bin
docker-topo 31KB
localtest.sh 265B
topo-extra-files
examples
v1-legacy
2-node.yml 205B
5-node-ls.yml 359B
mport.yml 359B
cvp.yml 19B
3-node.yml 225B
v2
2-node.yml 219B
5-node-ls.yml 508B
mdriver.yml 213B
2-node-intf.yml 151B
vmx-csr.yml 198B
macvlan.yml 312B
14rtr
14rtr_topology_draw.io.html 14KB
14rtr_topology.png 727KB
14rtr.yml 2KB
config
14rtr_rtr11 403B
14rtr_rtr05 605B
14rtr_rtr08 394B
14rtr_rtr04 604B
14rtr_rtr06 576B
14rtr_rtr12 403B
14rtr_rtr14 404B
14rtr_rtr02 464B
14rtr_rtr07 465B
14rtr_rtr13 404B
14rtr_rtr01 535B
14rtr_rtr10 402B
14rtr_rtr03 675B
14rtr_rtr09 397B
veos-3node.yml 282B
veth.yml 123B
openstack.yml 478B
cvp.yml 266B
vmx-csr-xrv.yml 222B
3-node.yml 332B
mini.yml 299B
config
veos_vEOS-1 18B
veos_vEOS-3 18B
veos_vEOS-2 18B
veos
entrypoint.sh.macvtap 3KB
10-intf.yaml 572B
entrypoint.sh 4KB
connect.sh 37B
rc.eos 250B
entrypoint.sh.old 3KB
Dockerfile 475B
test.sh 80B
.gitignore 10B
run.sh 272B
README.md 3KB
build.sh 306B
cvp
answers.yaml 454B
Dockerfile.new 428B
entrypoint.sh.new 1KB
entrypoint.sh 2KB
Dockerfile 611B
README.md 811B
build.sh 473B
host
entrypoint.sh 2KB
Dockerfile 423B
build.sh 43B
test
v1
v1-t1.sh 172B
v1-t1.yml 70B
v2
v2-t1.sh 278B
v2-t2.yml 322B
v2-t3.yml 322B
v2-t2.sh 281B
v2-t1.yml 295B
v2-t3.sh 281B
.gitignore 6B
README.md 11KB
共 76 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9149
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 图像识别实战项目-基于深度学习与多种应用领域的图像处理与分析
- golin 扫描工具使用, 检查系统漏洞、web程序漏洞
- 多种编程语言下的算法实现资源及其应用场景
- BGM坏了吗111111
- 高等工程数学试题详解:矩阵分析与最优化方法
- 这是一个以20位中国著名书法家的风格编写的汉字作品的数据集 每个子集中有1000-7000张jpg图像(平均5251张图像)
- 【Academic tailor】学术小裁缝必备知识点:全局注意力机制(GAM)pytorch
- 数据科学领域的主流数据集类型及其应用分析
- 【Academic tailor】学术小裁缝必备知识点:全局注意力机制(GAM)TensorFlow
- Apple MacBook Pro和macOS Monterey用户的全方位使用指南
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功