Docker Cookbook


| Chapter 3: Docker Networking



Download 6,31 Mb.
Pdf ko'rish
bet85/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   81   82   83   84   85   86   87   88   ...   260
Bog'liq
Docker Cookbook

92 | Chapter 3: Docker Networking


# ip tunnel add foo mode gre local 192.168.33.11 remote 192.168.33.12
# ip link set foo up
# ip addr add 172.17.127.254 dev foo
# ip route add 172.17.128.0/17 dev foo
If you did not use the Vagrantfile mentioned, replace the IP addresses for the 
local
and 
remote
endpoints in the preceding 
ip tunnel
command with the IP addresses of
your two Docker hosts. In the previous four commands, you created a GRE tunnel
named 
foo
. You brought the interface up and assigned an IP address to it. Then you
set up a route that sends all 
172.17.128.0/17
traffic in the tunnel.
On your second host, repeat the previous step to create the other end of the tunnel.
You call this other end 
bar
and set up a route that sends all 
172.17.0.0/17
traffic
over this tunnel:
# ip tunnel add bar mode gre local 192.168.33.12 remote 192.168.33.11
# ip link set bar up
# ip addr add 172.17.255.254 dev bar
# ip route add 172.17.0.0/17 dev bar
Once the tunnel is up, verify that you can ping back and forth using the tunnel. Now
let’s bring up Docker on both hosts. First you need to configure each Docker daemon
so that it uses the appropriate subnets for its containers and uses the correct IP
address for the 
docker0
bridge. To do this, you edit the Docker daemon configura‐
tion file and use the 
--bip
and 
--fixed-cidr
options.
On host 1 that would be as follows:
# echo DOCKER_OPTS=\"--bip=172.17.0.1/17 --fixed-cidr=172.17.0.0/17\" \
>> /etc/default/docker
And on host 2:
# echo DOCKER_OPTS=\"--bip=172.17.128.1/17 --fixed-cidr=172.17.128.0/17\" \
>> /etc/default/docker
If you have chosen a different partitioning schema or have more than two hosts,
repeat this with your values.
Since Docker will turn on IP forwarding, all traffic on 
docker0
will
get forwarded to 
foo
and 
bar
, so there is no need to attach the tun‐
nel endpoints to any bridges.
All that is left now is to restart Docker. Then you can start one container on each host
and you will see that they have direct network connectivity using the private IP
address given to them by Docker.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   81   82   83   84   85   86   87   88   ...   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