Docker Cookbook



Download 6,31 Mb.
Pdf ko'rish
bet218/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   214   215   216   217   218   219   220   221   ...   260
Bog'liq
Docker Cookbook

import
json
import
docker
import
sys
278 | Chapter 9: Monitoring Containers


cli
=
docker
.
Client
(
base_url
=
'unix://var/run/docker.sock'
)
events
=
cli
.
events
(
since
=
sys
.
argv
[
1
],
until
=
sys
.
argv
[
2
])
for
e
in
events
:
print
e
This script takes two timestamps as arguments and returns the events between these
two. An example output is as follows:
$ ./events.py 1427890602 1427891476
{"status":"untag","id":"967a84db1eff36cab6e77fe9c9393146c...","time":1427890624}
{"status":"untag","id":"4986bf8c15363d1c5d15512d5266f8777...","time":1427890629}
{"status":"untag","id":"4986bf8c15363d1c5d15512d5266f8777...","time":1427890642}
{"status":"delete","id":"4986bf8c15363d1c5d15512d5266f877...","time":1427890643}
{"status":"delete","id":"ea13149945cb6b1e746bf28032f02e9b...","time":1427890643}
{"status":"delete","id":"df7546f9f060a2268024c8a230d86398...","time":1427890643}
Event-based tools like 
StackStorm
 take advantage of this to orchestrate various parts
of a Docker base infrastructure.
See Also
• API 
documentation
9.4 Getting the Logs of a Container with docker logs
Problem
You have a running container that runs a process in the foreground within the con‐
tainer. You would like to access the process logs from the host.
Solution
Use the 
docker logs
command.
For example, start an Nginx container and open your browser on port 80 of the
Docker host:
$ docker run -d -p 80:80 nginx
$ docker ps
CONTAINER ID IMAGE ... PORTS NAMES
dd0e926c4015 nginx:latest ... 443/tcp, 0.0.0.0:80->80/tcp gloomy_mclean
$ docker logs gloomy_mclean
192.168.34.1 - - [10/Mar/2015:10:12:35 +0000] "GET / HTTP/1.1" 200 612 "-" ...
...

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   214   215   216   217   218   219   220   221   ...   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