Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Docker Networking 詳解
Search
Rueian
October 27, 2016
Technology
370
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Docker Networking 詳解
介紹 Bridge Driver、Host Driver、Macvlan Driver、還有 Swarm Overlay Network 如何運作
Rueian
October 27, 2016
More Decks by Rueian
See All by Rueian
DDIA Chapter 9 Notes
rueian
0
450
Cilium's Envoy Filter and VS Bridge to Kubernetes
rueian
0
1.7k
Cilium & cgroup eBPF
rueian
0
1.6k
Golang PostgreSQL Libraries Comparison With Wireshark
rueian
0
1.4k
Scaling Offline Database Usage on GCP @ Dcard
rueian
1
880
Other Decks in Technology
See All in Technology
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
350
DevelopersIO 2026 Tokyo 現時点の衛星通信サービスの現状を整理してみる
maroon1st
0
200
初海外で注意すべきこと12選!!!安全快適なre:invent生活にするために
yuuuuuuu168
1
200
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
150
DBについての基礎説明(MySQL編) - コロプラ 2026年度 新卒研修
colopl
0
160
From Developer Experience to Agentic Experience: The Next Evolution of APIs
benjagm
0
110
『SAR衛星データ解析入門』のご紹介とその応用
syuchimu
0
140
AI導入は済んだ。次は統制を作り替える番だ_AI×開発組織 Summit 2026
techtekt
PRO
0
520
日本AIベンチャーレポート2026
kentarofujii
0
120
What Is JetBrains Air
x5gtrn
PRO
0
150
How to teach your AI Agent with Agent skills
linedevth
0
110
オントロジーって 結局なにもの? AI エージェントに「意味」を渡す知識設計の話
greenmidori
0
260
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
560
We Have a Design System, Now What?
morganepeng
55
8.4k
Amusing Abliteration
ianozsvald
1
350
Skip the Path - Find Your Career Trail
mkilby
1
260
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
840
First, design no harm
axbom
PRO
2
1.3k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
610
Odyssey Design
rkendrick25
PRO
2
880
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Building Adaptive Systems
keathley
44
3.3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Transcript
Docker Networking Rueian docker engine 1.12
內建的 Driver • null • bridge • host • macvlan
• overlay in swarm
Bridge Driver • 預設 bridge driver 在創建網路路的時候會在 linux 上⾯面開⼀一張 interface,可能叫做
br-xxxx,並利利⽤用 iptables NAT 連接外網。 • 當有容器加入該網路路的時候,docker 會為該容器創建⼀一個 linux network namespaces,然後再創建⼀一對互相連接的 veth peer,將其中⼀一個 veth 放置於該 namespace 底下,另外⼀一個 veth 則與 br-xxxx 做 bridge。如此⼀一來來就完成容器的網路路設 定。 • 若若容器有指定 -p 對外開放 port 的話,則是透過 iptables 做 DNAT 達成。
關於 Network Namespace & veth pair Network Namespace 可以創建出 ⼀一個虛擬化的網路路環境。
Namespace 透過 veth peer 與外界連接。 圖片出處:http://www.slideshare.net/zuan0312/linux-network-namespace
預設的 docker0 就是 bridge 圖片來來源:http://www.slideshare.net/MadhuVenugopal2/docker-112-networking-deep-dive
試試⼿手動將容器加入 docker0
試試⼿手動將容器加入 docker0
試試⼿手動將容器加入 docker0 圖片來來源:https://docs.docker.com/v1.8/articles/networking/
Host Driver • host network 不會創建 netwrok namespace,也不 會創 veth
pair,⽽而是直接使⽤用 host 的 network stack • docker run --net=host busybox ifconfig 可以發現輸 出跟直接在 host 下 ifconfig ⼀一模⼀一樣。
Macvlan Driver • 當 docker 需要接入外⾯面 802.1Q vlan 的時候,要⽤用 macvlan
driver。 • docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 macvlan50 • 需要指定 vlan 對應的 subnet 以及 gateway 還有 parent 的 interface, 利利如 eth0.50 • 如果 docker 找不到 parent interface,則會⾃自動創建。 若若要⾃自⼰己創則: ip link add link eth0 name eth0.50 type vlan id 50 不過 docker 可以⾃自動管理理這些 sub interface,就算重開機後 docker 也 可以把這些 interface ⾃自動創建回來來。
Macvlan Driver 圖片來來源:https://github.com/docker/libnetwork/blob/master/docs/macvlan.md 將三個容器個別加入到三個 vlan
Overlay in Swarm • Overlay network 由 data plane 跟
control plane 組 成。 data plane 負責傳送資料,control plane 負責 保存傳遞 routing 跟 service discovery 訊息。 • 在 docker swarm 中,data plane 封包傳遞採⽤用 vxlan 格式包裝,還可以再套⼀一層 IPSec tunnel 加 密。control plane 採⽤用 Gossip based protocol,使 ⽤用 AES 加密,每⼗十⼆二⼩小時會換 key,且⽤用 decentralize store 保存資訊。
Networking in Swarm • swarm 模式開啟時, docker 會先創建⼀一個 docker_gwbridge bridge
network,透過 iptables 做 NAT,作為對外的 gateway,跟 docker0 ⼀一樣。 • 除此之外還會創建⼀一個 ingress overlay network,以及 ⼀一個 ingress sbox namespace。所有的 swarm service container 都會加入 ingress overlay network。 ⽽而這個 ingress sbox 將會透過 ingress overlay network 完成 docker swarm 的 port-publish, routing mesh, loadbalancing 功能。
圖片來來源:http://www.slideshare.net/MadhuVenugopal2/docker-112-networking-deep-dive
Networking in Swarm • docker service create --replicas 1 \
-p 8080:80 \ --network my-overlay \ nginx • port-publish: docker 會將所有 node 的 8080 port 透過 iptables DNAT 設定把流 量量導入各⾃自的 ingress sbox。 • routing mesh + ingress loadbalancing: 流量量進入 ingress sbox 之後會透過 iptables 打上對應的 firewall mark 再交給 IPVS 去根據 mark 找到 nginx 在 ingress overlay network 的 ip 列列表然後做 RR loadbalancing。
圖片來來源:http://www.slideshare.net/MadhuVenugopal2/docker-112-networking-deep-dive
Networking in Swarm • 若若想要在 swarm 裡⾯面直接連接內部服務,必須他們 加入同⼀一個非 ingress 的
overlay 網路路。 • 在同⼀一個 overlay 網路路的 container 可以透過 service name 去跟 embedded DNS 查詢 VIP 再透過 iptables 打上 mark 再交給 IPVS 根據 mark 去 RR 存 取服務。
圖片來來源:http://www.slideshare.net/MadhuVenugopal2/docker-112-networking-deep-dive
參參考 • Docker 1.12 networking deep dive • 簡介 Linux
的 Network Namespace 功能 • Docker libnetwork design • https://github.com/docker/libnetwork/blob/master/docs/macvlan.md • overlay網路路技術之VXLAN詳解 • IPVS 百度 • Swarm mode overview • Understand Docker container networks • https://docs.docker.com/v1.8/articles/networking/