Docker Cookbook


Getting Detailed Information About a Container with docker inspect | 275



Download 6,31 Mb.
Pdf ko'rish
bet215/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   211   212   213   214   215   216   217   218   ...   260
Bog'liq
Docker Cookbook

9.1 Getting Detailed Information About a Container with docker inspect | 275


If you prefer to use another Docker client such as 
docker-py
(see 
Recipe 4.10
), you
can also access the detailed information about containers and images by using stan‐
dard Python dictionary notation:
$ python
...
>>> from docker import Client
>>> c=Client(base_url="unix://var/run/docker.sock")
>>> c.inspect_container('kickass_babbage')['State']['Running']
True
>>> c.inspect_container('kickass_babbage')['NetworkSettings']['IPAddress']
u'172.17.0.3'
9.2 Obtaining Usage Statistics of a Running Container
Problem
You have a running container on one of your Docker hosts and would like to monitor
its resource usage (e.g., memory, CPU, network).
Solution
Use the 
docker stats
command. This new API endpoint was introduced on Febru‐
ary 10, 2015 and is accessible in Docker 1.5. The usage syntax is simple: you pass the
container name (or container ID) to it and receive a stream of statistics. Here you
start a Flask application container and run 
stats
on it:
$ docker run -d -p 5000:5000 runseb/flask
$ docker stats dreamy_mccarthy
CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O
dreamy_mccarthy 0.03% 24.01 MiB/1.955 GiB 1.20% 648 B/648 B
Since you are receiving a stream, you will not press the Ctrl-C keys to kill the stream.
Discussion
Getting quick stats from the command line is useful for interactive debugging. How‐
ever, you will most likely want to collect all these statistics and aggregate them with a
log collector solution like 
Logstash
for futher visualization and analysis.
To prepare for such a monitoring framework, you can try to use the 
stats
API via
curl
, by issuing TCP requests to the Docker daemon. First you will need to configure
your local Docker daemon to listen on port 2375 over TCP. On Ubuntu systems,
edit 
/etc/default/docker
to include the following:
DOCKER_OPTS="-H tcp://127.0.0.1:2375"

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   211   212   213   214   215   216   217   218   ...   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