dockermacvlan的简单介绍

本篇文章给大家谈谈dockermacvlan,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

Docker 网络 macvlan模式

本文翻译自docker官网:

Some applications, especially legacy applications or applications which monitor

network traffic, expect to be directly connected to the physical network. In

this type of situation, you can use the macvlan network driver to assign a MAC

address to each container's virtual network interface, making it appear to be

a physical network interface directly connected to the physical network. In this

case, you need to designate a physical interface on your Docker host to use for

the macvlan , as well as the subnet and gateway of the macvlan . You can even

isolate your macvlan networks using different physical network interfaces.

Keep the following things in mind:

When you create a macvlan network, it can either be in bridge mode or 802.1q

trunk bridge mode.

To create a macvlan network which bridges with a given physical network

interface, use --driver macvlan with the docker network create command. You

also need to specify the parent , which is the interface the traffic will

physically go through on the Docker host.

If you need to exclude IP addresses from being used in the macvlan network, such

as when a given IP address is already in use, use --aux-addresses :

If you specify a parent interface name with a dot included, such as eth0.50 ,

Docker interprets that as a sub-interface of eth0 and creates the sub-interface

automatically.

In the above example, you are still using a L3 bridge. You can use ipvlan

instead, and get an L2 bridge. Specify -o ipvlan_mode=l2 .

If you have configured the Docker daemon to allow IPv6 ,

you can use dual-stack IPv4/IPv6 macvlan networks.

Docker macvlan

默认情况下docker使用bridge网络,这是一个私有网络,只能在host和container之间互通,如果发布服务,需要使用端口映射的方式来解决,比如一个nginx容器要想对外提供服务则在容器启动时指定参数 -p 80:80 ,然后使用host主机的ip加端口即可访问容器。这在大部分场景下都够用了,但是总有一些需求无法满足,比如如果多个容器都需要使用80端口,或者只使用ip通信的网络应用, macvlan 可以做到。

macvlan 是可以虚拟mac地址,单独的macvlan存在意义不大,结合docker给每一个容器都虚拟一个 mac 地址,这样每个容器在局域网中都相当于一个独立的主机。

经过上面操作运行了一个耐段nginx容器,此容器拥有一个虚拟的mac地址,在网内相当于一个真实的主机,任何网内的其他主机(非host)都可以通过为其指定的ip访问该容器。

如果使用相同的方法运行多个nginx容器,并不需要每个容器指定不同的端口,因为网络namespace是隔离的。

但是目前有个问题: host 和 container 是无法互通的,因为是macvlan的原因,同一个网口的流量纳亩肆是无法回传的,除非在外部有一个支持 VEPA 或者 VN-Link 的交换机。

以上洞轿命令中的网络接口、ip请根据实际情况进行调整

docker中macvlan网络模式

群晖docker网卡原来为macvlan模式,虚拟机获取与群晖在同一网段IP;

聚合后,docker虚拟机不能正常开启,删除原先macvlan网络,重新绑定至仿迹bond网胡含卡裤大笑;

docker network create -d macvlan --subnet=192.168.172.0/24 --gateway=192.168.172.254 -o parent=ovs_bond0 bridge-host

命令解释:

[img]

关于dockermacvlan和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

标签列表