Docker Cookbook


Using fleet to Start Containers on a CoreOS Cluster



Download 6,31 Mb.
Pdf ko'rish
bet146/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   142   143   144   145   146   147   148   149   ...   260
Bog'liq
Docker Cookbook

6.4 Using fleet to Start Containers on a CoreOS Cluster
Problem
You have a working CoreOS cluster and would like to start containers on it.
Solution
With a CoreOS cluster in hand (see 
Recipe 6.3
), use the 
fleetctl
CLI to start your
containers. You write 
systemd
units describing those running containers and use
fleetctl start
to schedule them on the cluster.
For example, consider how you started a container via 
cloud-init
in 
Recipe 6.2
. You
can extract the following 
systemd
unit to start an Elasticsearch container on a cluster
(let’s call it 
es.service
):
[Unit]
After=docker.service
178 | Chapter 6: Optimized Operating System Distributions for Docker


Requires=docker.service
Description=starts Elastic Search container
[Service]
TimeoutStartSec=0
ExecStartPre-=/usr/bin/docker kill es
ExecStartPre-=/usr/bin/docker rm es
ExecStartPre=/usr/bin/docker pull dockerfile/elasticsearch
ExecStart=/usr/bin/docker run --name es -p 9200:9200 \
-p 9300:9300 \
dockerfile/elasticsearch
ExecStop=/usr/bin/docker stop es
Start this container with 
fleetctl
:
$ vagrant ssh core-01
$ fleetctl start es.service
$ fleetctl list-units
UNIT MACHINE ACTIVE SUB
es.service 01efec94.../172.17.8.102 activating start-pre
$ fleetctl list-units
UNIT MACHINE ACTIVE SUB
es.service 01efec94.../172.17.8.102 active running
fleet
will schedule the unit on one of the nodes in your cluster. 
systemd
will run the
es.service
unit, which will start by downloading the image. Once the image is
downloaded, it will run the container defined in the 
ExecStart
step of the unit file.
Discussion
The 
fleet
CLI 
fleetctl
comes with some nice commands to check the journal of
the unit, destroy it, and 
ssh
to the nodes that have been tasked with running the unit.
These commands can come in handy during debugging steps:
$ fleetctl list-units
UNIT MACHINE ACTIVE SUB
es.service 01efec94.../172.17.8.102 active running
$ fleetctl ssh es.service
Last login: Mon Jan 12 22:03:29 2015 from 172.17.8.101
CoreOS (stable)
core@core-02 ~ $ docker ps
CONTAINER ID IMAGE COMMAND ...
6fc661ba2153 dockerfile/elasticsearch:latest "/elasticsearch/bin/ ...
core@core-02 ~ $ exit
$ fleetctl journal es.service
-- Logs begin at Mon 2015-01-12 17:50:47 UTC, end at Mon 2015-01-12 22:13:20 UTC
Jan 12 22:06:13 core-02 ...[node ] [Wendigo] initializing ...
Jan 12 22:06:13 core-02 ...[plugins ] [Wendigo] loaded [], sites []
Jan 12 22:06:17 core-02 ...[node ] [Wendigo] initialized
Jan 12 22:06:17 core-02 ...[node ] [Wendigo] starting ...
Jan 12 22:06:17 core-02 ...[transport ] [Wendigo] bound_address ...
Jan 12 22:06:17 core-02 ... discovery ] [Wendigo] elasticsearch/_NcgQa...

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   142   143   144   145   146   147   148   149   ...   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