跳转至

网络


Docker网络架构源自一种叫做容器网络模型(CNM)的方案。
libnetwork是Docker对CNM的一种实现。

基础

Docker网络架构由3个主要部分构成:CNM,Libnetwork和驱动。

命令

Bash
1
docker network --help

种类

类型 描述
bridge The default network driver.
host 容器使用主机网络
none 不适用网络
overlay Overlay networks connect multiple Docker daemons together.
ipvlan IPvlan networks provide full control over both IPv4 and IPv6 addressing.
macvlan Assign a MAC address to a container.

macvlan

Bash
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#加载macvlan内核模块
sudo modprobe macvlan

#检测加载是否成功
lsmod | grep macvlan1.创建docker网络设备

#创建macvlan
sudo docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o parent=eth0 macvlan1

docker run --network=my_macvlan_net --ip=192.168.1.123 -it --rm ubutnu