Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
unsignedcpp
docker_practice
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
docker_practice
/
advanced_network
/
docker0.md
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
37 lines (28 loc) · 1.9 KB
master
Breadcrumbs
docker_practice
/
advanced_network
/
docker0.md
Copy path
Top
File metadata and controls
Code
Blame
37 lines (28 loc) · 1.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#
配置
docker0
网桥
Docker
服务默认会创建一个
`docker0`
网桥
(
其上有一个
`docker0`
内部接口
),
它在内核层连通了其他的物理或虚拟网卡
,
这就将所有容器和本地主机都放到同一个物理网络
。
Docker
默认指定了
`docker0`
接口
的
IP
地址和子网掩码
,
让主机和容器之间可以通过网桥相互通信
,
它还给出了
MTU
(
接口允许接收的最大传输单元
),
通常是
1500
Bytes
,
或宿主主机网络路由上支持的默认值
。
这些值都可以在服务启动的时候进行配置
。
*
`--bip=CIDR`
IP
地址加掩码格式
,
例如
192.168
.1
.
5
/
24
*
`--mtu=BYTES`
覆盖默认的
Docker
mtu
配置
也可以在配置文件中配置
DOCKER_OPTS
,
然后重启服务
。
由于目前
Docker
网桥是
Linux
网桥
,
用户可以使用
`brctl show`
来查看网桥和端口连接信息
。
``
`bash
$ sudo brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.3a1d7362b4ee no veth65f9
vethdda6
`
``
*
注
:
`brctl`
命令在
Debian
、
Ubuntu
中可以使用
`sudo apt-get install bridge-utils`
来安装
。
每次创建一个新容器的时候
,
Docker
从可用的地址段中选择一个空闲的
IP
地址分配给容器的
eth0
端口
。
使用本地主机上
`docker0`
接口的
IP
作为所有容器的默认网关
。
``
`bash
$ sudo docker run -i -t --rm base /bin/bash
$ ip addr show eth0
24: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 32:6f:e0:35:57:91 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.3/16 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::306f:e0ff:fe35:5791/64 scope link
valid_lft forever preferred_lft forever
$ ip route
default via 172.17.42.1 dev eth0
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.3
`
``
You can’t perform that action at this time.