Docker Cookbook


| Chapter 3: Docker Networking



Download 6,31 Mb.
Pdf ko'rish
bet66/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   62   63   64   65   66   67   68   69   ...   260
Bog'liq
Docker Cookbook

72 | Chapter 3: Docker Networking


You will see that the mapping was done automatically.
Discussion
You can expose multiple container ports and choose TCP or UDP protocols; for
example, if you wanted to expose port 5000 over TCP and port 53 over UDP (assum‐
ing your application uses port 53 as well), you would do this:
$ docker run -d -p 5000/tcp -p 53/udp flask
This port mapping is made possible via two mechanisms.
First, by default Docker can manipulate the IP table of the host. If you check your IP
tables rules when running the preceding Flask application, you will find a new rule in
the Docker chain:
$ sudo iptables -L
...
Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:5000
Second, Docker starts a small proxy on your host that listens on the host interface
using the port that was chosen dynamically. If you list the processes, you will find
this:
$ ps -ef | grep docker
root 29969 1 ... /usr/bin/docker -d
root 30851 29969 ... docker-proxy -proto tcp -host-ip 0.0.0.0 \
-host-port 32769 \
-container-ip 172.17.0.5 \
-container-port 5000
You could change this default behavior by not allowing Docker to change your 
ipta
bles
but you will have to handle networking on your own (see 
Recipe 3.6
).
3.3 Linking Containers in Docker
Problem
When building a distributed application that is made of several services, you need a
way to discover where those services are so that various components of the system
can reach the other ones. You could manually extract IP addresses of each service
(running in a container), but in order to scale, you need a self-discovery system.
3.3 Linking Containers in Docker | 73



Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   62   63   64   65   66   67   68   69   ...   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