Docker Cookbook


Starting Containers on a Cluster with Docker Swarm | 199



Download 6,31 Mb.
Pdf ko'rish
bet162/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   158   159   160   161   162   163   164   165   ...   260
Bog'liq
Docker Cookbook

7.3 Starting Containers on a Cluster with Docker Swarm | 199


docker
pull
swarm
SCRIPT
.
.
.
Once the nodes are up and Vagrant has returned, 
ssh
to the head node and start a
Swarm container by using the 
swarm
image that was pulled during the bootstrap
process:
$ vagrant ssh swarm-head
$ docker run -v /vagrant:/tmp/vagrant -p 1234:1234 -d swarm manage \
file://tmp/vagrant/swarm-cluster.cfg -H=0.0.0.0:1234
72acd5bc00de0b411f025ef6f297353a1869a3cc8c36d687e1f28a2d8f422a06
The Swarm server setup uses a file-based discovery mechanism.
The 
swarm-cluster.cfg
file contains the hardcoded lists of the Swarm
nodes started by Vagrant. Additional discovery 
services
are avail‐
able for Swarm. You can use a service hosted by Docker Inc., 
Con‐
sul

Etcd
, or 
ZooKeeper
. You can also write your own discovery
interface.
With the Swarm server running and the worker nodes discovered, you will be able to
use the local Docker client to get information about the cluster and start containers.
You will need to use the 
-H
option of the Docker CLI to target the Swarm server run‐
ning in a container instead of the local Docker daemon:
$ docker -H 0.0.0.0:1234 info
Containers: 0
Nodes: 3
swarm-2: 192.168.33.12:2375
└ Containers: 0
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 490 MiB
swarm-3: 192.168.33.13:2375
└ Containers: 0
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 490 MiB
swarm-1: 192.168.33.11:2375
└ Containers: 0
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 490 MiB
Using the local Docker client and specifying the Swarm server as a Docker daemon
endpoint, you can start containers on the entire cluster. For example, let’s start Nginx:
$ docker -H 0.0.0.0:1234 run -d -p 80:80 nginx
8399c544b61953fd5610b01be787cb3802e2e54f220673b94d78160d0ee35b33
$ docker -H 0.0.0.0:1234 run -d -p 80:80 nginx
1b2c4634fc6d9f2c3fd63dd48a2580f466590ddff7405f889ada885746db3cbd
$ docker -H 0.0.0.0:1234 ps
CONTAINER ID IMAGE ... PORTS NAMES

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   158   159   160   161   162   163   164   165   ...   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