Docker Cookbook


See Also • Apache Mesos  configuration 7.12 Using the Mesos Docker Containerizer on a Mesos Cluster | 225



Download 6,31 Mb.
Pdf ko'rish
bet181/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   177   178   179   180   181   182   183   184   ...   260
Bog'liq
Docker Cookbook

See Also
• Apache Mesos 
configuration
7.12 Using the Mesos Docker Containerizer on a Mesos Cluster | 225


7.13 Discovering Docker Services with Registrator
Problem
You are building a distributed application with services based on containers started
on multiple hosts. You need to automatically discover these services to configure your
application. This is needed when services migrate from one host to another or when
they are started automatically.
Solution
Use 
registrator
. It runs as a container on the hosts in your system. By mounting the
Docker socket 
/var/run/docker.sock
, it listens to containers that come and go, and reg‐
isters or unregisters them on a data store backend. Several backend data stores are
available (e.g., 
etcd

Consul
, and SkyDNS 2), and registrator can possibly support
more. These service registries are not specific to Docker even though 
etcd
comes
bundled in the CoreOS distribution (see 
Recipe 6.3
).
To use 
registrator
, you first need to set up one backend for service registries. Since
these are available as static binaries, you can download them and run them in the
foreground for testing. For example, to use 
etcd
:
$ curl -L https://github.com/coreos/etcd/releases/download/v0.4.6/\
etcd-v0.4.6-linux-amd64.tar.gz
-o etcd-v0.4.6-linux-amd64.tar.gz
$ tar xzvf etcd-v0.4.6-linux-amd64.tar.gz
$ cd etcd-v0.4.6-linux-amd64
$ sudo ./etcd
2015/03/26 14:02:21 no data-dir provided, using default data-dir ./default.etcd
2015/03/26 14:02:21 etcd: listening for peers on http://localhost:2380
2015/03/26 14:02:21 etcd: listening for peers on http://localhost:7001
2015/03/26 14:02:21 etcd: listening for client requests on http://localhost:2379
2015/03/26 14:02:21 etcd: listening for client requests on http://localhost:4001
...
Leave 
etcd
running. In another terminal session, create a directory in the 
etcd
key-
value store (e.g., 
cookbook
in the following code). This directory will hold the services
when they are discovered:
$ cd etcd-v0.4.6-linux-amd64
$ ./etcdctl mkdir cookbook
$ ./etcdctl ls
/cookbook
Then download the 
registrator
image from Docker Hub and run it:
$ docker pull gliderlabs/registrator
$ docker run -d -v /var/run/docker.sock:/tmp/docker.sock
-h 192.168.33.10

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   177   178   179   180   181   182   183   184   ...   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