当前位置:网站首页>Container network: free days, don't buy an apartment and rent it together
Container network: free days, don't buy an apartment and rent it together
2022-07-21 14:28:00 【Zhang quandan, Foxconn quality inspector】
How to integrate physical network into container network ?
Understand the technology behind the container , So let's see , How does the container network integrate into the physical network ? If you use docker run Run a container , You should see such a topology .
Is it similar to virtual machine ? There is a network card in the container , There is a network card outside the container , The network card outside the container is connected to docker0 bridge , Through this bridge , Containers directly implement mutual access .
If you use brctl see docker0 bridge , You will find that it is connected with some network cards .
Is the network card connecting the container and the bridge the same as the virtual machine ? In the virtual machine scenario , There is a virtualization software , adopt TUN/TAP The device virtualizes a network card to the virtual machine , But there is no virtualization software in the container scenario , What should I do ?
stay Linux Next , You can create a pair of veth pair Network card of , Send packets from one side , The other side will receive .
We first create such a pair through this command .
ip link add name veth1 mtu 1500 type veth peer name veth2 mtu 1500
One side can hit docker0 On the bridge .
ip link set veth1 master testbr
ip link set veth1 up
How to put the other end into the container ? The startup of a container will correspond to one namespace, We need to find this first namespace. about docker Speaking of ,pid Namely namespace Name , You can get it from this command .
docker inspect '--format={
{ .State.Pid }}' test
Assume the result is 12065, This is namespace name .
Default Docker Network created namespace Not in the default path ,ip netns Out of sight , So we need to ln Soft link . After linking , We can go through ip netns The command operates .
rm -f /var/run/netns/12065
ln -s /proc/12065/ns/net /var/run/netns/12065
then , We can put the other end veth2 Plug into the namespace Inside .
ip link set veth2 netns 12065
then , Rename the network card in the container .
ip netns exec 12065 ip link set veth2 name eth0
then , Set the network card in the container ip Address .
ip netns exec 12065 ip addr add 172.17.0.2/16 dev eth0
ip netns exec 12065 ip link set eth0 up
There is no problem with the mutual access of containers inside a machine , How to access the Internet ?
边栏推荐
- RT-thread-2022夏令营-学习总结-第二天
- Simple student management system project: (add, delete, check, change, fuzzy check, paging check, upload, download, video import, current system time) -- "source code attached"
- 2022年7月俄罗斯数据库排行榜:ClickHouse雄踞榜首,GigaBASE摘得榜眼
- Regular expressions from entry to entry
- ThreadLocal详解
- 小镇做题家的DBA之路
- Redis实现分布式限流(学习笔记
- Commercial supply chain management system of big health industry: standardize procurement management and improve enterprise procurement efficiency
- oh my god
- 消息称苹果继续向俄罗斯市场交付产品:不进行售卖,只用于退换货
猜你喜欢
随机推荐
Is it OK to open an account with flush? Is it safe?
Win11 22H2怎么卸载更新补丁?Win11 22H2卸载更新补丁的步骤
Win11C盘变红怎么办?Win11C盘变红的清理方法
学习笔记(1)初识uni-app
搭建简易动态ip代理池
强引用、弱引用、软引用、虚引用
In the era of UCA, how can the enterprise supply chain respond to the enterprise procurement expenditure management quickly?
What if win11 C disk turns red? Cleaning method of win11 C disk turning red
墨天轮高分技术文档分享——数据库安全篇(共48个)
Is it safe for Orient Fortune Securities to open an account? What is the lowest commission?
mysql基础
STL notes (XII): relevance container - set
Is it safe to open an account in flush? How much commission can you give?
基于B\S架构搭建属于自己的股票分析系统
Redis implements distributed current limiting (learning notes
Oserror: [winerror 1455] the page file is too small to complete the operation.
矩阵初始化的缺陷
读书笔记(一)——《追风筝的人》
PCL calculates point cloud roughness
Go语言 包管理