Docker Cookbook


| Chapter 3: Docker Networking



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

88 | Chapter 3: Docker Networking


Solution
Create a bridge and change the start-up options of the Docker daemon to use it.
In the 
Recipe 3.7
 solution section, you saw how to create a full networking stack for a
container started with the 
--net=none
option. That section showed how to create a
bridge. Let’s reuse what we discussed there.
First let’s turn off the Docker daemon, delete the 
docker0
bridge created by default,
and create a new bridge called 
cookbook
:
$ sudo service docker stop
$ sudo ip link set docker0 down
$ sudo brctl delbr docker0
$ sudo brctl addbr cookbook
$ sudo ip link set cookbook up
$ sudo ip addr add 10.0.0.1/24 dev cookbook
Now that the bridge is up, you can edit the Docker daemon configuration file and
restart the daemon (e.g., on Ubuntu):
$ sudo su
# echo 'DOCKER_OPTS="-b=cookbook"' >> /etc/default/docker
# service docker restart
You can start a container and list the IP address assigned to it and check network
connectivity:
root@c557cdb072ba:/# ip addr show eth0
10: eth0: mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:0a:00:00:02 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.2/24 scope global eth0
...
Automatically as expected, Docker also creates the NAT rule for this bridge:
$ sudo iptables -t nat -L
...
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 10.0.0.0/24 anywhere
Discussion
Although you can do this manually, there is nothing different between the bridge
cookbook
that you just created and the default 
docker0
bridge.
If you wanted to change the IP range that Docker uses for the containers started with
the default networking (i.e., bridge), you could use the 
--bip
option. You could also
restrict this IP range with the 
--fixed-cidr
option as well as set the MTU size with
--mtu
.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   77   78   79   80   81   82   83   84   ...   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