docker0, Docker Bridge Driver 和容器之间的关系
Relationship between docker0, Docker Bridge Driver and Containers
我正在观看 YouTube video on Docker networking 并看到这张幻灯片:
我正在努力理解它。来自 docker0
docs:
"By default, the Docker server creates and configures the host system’s docker0
a network interface called docker0
, which is an ethernet bridge device. If you don’t specify a different network when starting a container, the container is connected to the bridge and all traffic coming from and going to the container flows over the bridge to the Docker daemon, which handles routing on behalf of the container."
但我对这里的交通流量还是有点不解。假设我在新主机上安装 Docker。我假设 docker0
是在安装时创建和配置的。所以现在我的主机上有这个 docker0
以太网桥。
现在假设我在我的新 Docker 主机上启动了一个容器:
docker run -it -p 9200:9200 -d --name myapp myapp
由于我没有指定网络驱动程序,因此默认情况下为我选择了 bridge
。根据上面文档中的简介,容器现在应该 sending/receiving 通过 docker0
桥的流量。但是,在上图中,指示没有流量从 docker0
、 流向 to/from 基于桥接的容器(C4、C5、C6),我想知道: 为什么?! 有什么想法吗?提前致谢!
你是对的,那个方案不符合正在发生的事情。我没有看到视频,也许 "picture" 是一个具体时刻的快照。或许我们应该看看视频来了解上下文。
无论如何,当 Docker 创建 docker0
接口时,有一些使用新链创建的 iptables 规则(DOCKER 和 DOCKER-ISOLATION ).默认情况下,Docker 个容器只能从您的主机访问。然后在 docker 运行 命令上使用 -p
选项,您可以将端口从主机直接映射到容器。这样做你可以到达你的主机上真正在容器上的某个端口。您可以使用 iptables -t nat -L
在容器 运行 之前和之后检查 NAT table。您将看到映射的差异和规则。
是的,容器是在同一个网络上创建的,它们可以尝试在该网络上进行通信。默认情况下,用于 docker 的网络范围是 172.17.0.0/16 所以你的第一个容器是 172.17.0.2 第二个是 172.17.0.3 等等。 (172.17.0.1 是您的 docker0 ip)。
我正在观看 YouTube video on Docker networking 并看到这张幻灯片:
我正在努力理解它。来自 docker0
docs:
"By default, the Docker server creates and configures the host system’s
docker0
a network interface calleddocker0
, which is an ethernet bridge device. If you don’t specify a different network when starting a container, the container is connected to the bridge and all traffic coming from and going to the container flows over the bridge to the Docker daemon, which handles routing on behalf of the container."
但我对这里的交通流量还是有点不解。假设我在新主机上安装 Docker。我假设 docker0
是在安装时创建和配置的。所以现在我的主机上有这个 docker0
以太网桥。
现在假设我在我的新 Docker 主机上启动了一个容器:
docker run -it -p 9200:9200 -d --name myapp myapp
由于我没有指定网络驱动程序,因此默认情况下为我选择了 bridge
。根据上面文档中的简介,容器现在应该 sending/receiving 通过 docker0
桥的流量。但是,在上图中,指示没有流量从 docker0
、 流向 to/from 基于桥接的容器(C4、C5、C6),我想知道: 为什么?! 有什么想法吗?提前致谢!
你是对的,那个方案不符合正在发生的事情。我没有看到视频,也许 "picture" 是一个具体时刻的快照。或许我们应该看看视频来了解上下文。
无论如何,当 Docker 创建 docker0
接口时,有一些使用新链创建的 iptables 规则(DOCKER 和 DOCKER-ISOLATION ).默认情况下,Docker 个容器只能从您的主机访问。然后在 docker 运行 命令上使用 -p
选项,您可以将端口从主机直接映射到容器。这样做你可以到达你的主机上真正在容器上的某个端口。您可以使用 iptables -t nat -L
在容器 运行 之前和之后检查 NAT table。您将看到映射的差异和规则。
是的,容器是在同一个网络上创建的,它们可以尝试在该网络上进行通信。默认情况下,用于 docker 的网络范围是 172.17.0.0/16 所以你的第一个容器是 172.17.0.2 第二个是 172.17.0.3 等等。 (172.17.0.1 是您的 docker0 ip)。