Docker Cookbook


Using pipework to Understand Container Networking | 87



Download 6,31 Mb.
Pdf ko'rish
bet80/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   76   77   78   79   80   81   82   83   ...   260
Bog'liq
Docker Cookbook

3.7 Using pipework to Understand Container Networking | 87


for network namespaces. Doing so, you can list the existing network namespaces.
Next, you see that the namespace ID of your container is the container ID:
$ cd /var/run
$ sudo ln -s /var/run/docker/netns netns
$ sudo ip netns
c785553b22a1
$ NID=$(sudo ip netns)
Now, let’s put the 
bar
veth in the container namespace by using 
ip link set netns
and use 
ip netns exec
to give it a name and a MAC address inside this namespace:
$ sudo ip link set bar netns $NID
$ sudo ip netns exec $NID ip link set dev bar name eth1
$ sudo ip netns exec $NID ip link set eth1 address 12:34:56:78:9a:bc
$ sudo ip netns exec $NID ip link set eth1 up
The final thing to do is to assign an IP address to 
eth1
of the container and define a
default route so that the container can reach the Docker host and beyond:
$ sudo ip netns exec $NID ip addr add 192.168.1.1/24 dev eth1
$ sudo ip netns exec $NID ip route add default via 192.168.1.254
That’s it. At this stage, your container should have the exact same networking stack as
the one built with pipework earlier with a single command.
Remember that if you want to reach outside your container, you
need to add the IP NAT masquerading rule:
$ sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24
-j MASQUERADE
See Also

pipework’s
extensive 
README
covers multiple scenarios
• How Docker 
networks
 containers

ip netns
 man 
page
• Introduction to Linux nework 
namespace
3.8 Setting Up a Custom Bridge for Docker
Problem
You would like to set up your own bridge for Docker to use instead of using the
default.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   76   77   78   79   80   81   82   83   ...   260




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish