?
This document uses PHP Chinese website manual Release
從服務器獲取實時事件
docker system events [可選]
名字,簡寫 | 默認 | 描述 |
---|---|---|
--filter, -f | 根據(jù)提供的條件過濾輸出 | |
--format | 使用給定的Go模板格式化輸出 | |
--since | 顯示自時間戳以來創(chuàng)建的所有事件 | |
--until | 在此時間戳之前將事件流化 |
docker system df [OPTIONS]
名字,簡寫 | 默認 | 描述 |
---|---|---|
--format | 使用Go模板打印出漂亮的圖像 | |
--verbose,-v | 假 | 顯示空間使用情況的詳細信息 |
命令 | 描述 |
---|---|
docke系統(tǒng) | 管理Docker |
命令 | 描述 |
---|---|
docke系統(tǒng)df | 顯示docker磁盤使用情況 |
docker系統(tǒng)事件 | 從服務器獲取實時事件 |
docke系統(tǒng)信息 | 顯示系統(tǒng)范圍的信息 |
docker系統(tǒng)修剪 | 刪除未使用的數(shù)據(jù) |
docker system df
命令顯示有關docker守護程序使用的磁盤空間量的信息。
默認情況下,該命令只顯示所使用數(shù)據(jù)的摘要:
$ docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 5 2 16.43 MB 11.63 MB (70%)Containers 2 0 212 B 212 B (100%)Local Volumes 2 1 36 B 0 B (0%)
可以使用-v, --verbose
國旗:
$ docker system df -v Images space usage:REPOSITORY TAG IMAGE ID CREATED SIZE SHARED SIZE UNIQUE SIZE CONTAINERS my-curl latest b2789dd875bf 6 minutes ago 11 MB 11 MB 5 B 0my-jq latest ae67841be6d0 6 minutes ago 9.623 MB 8.991 MB 632.1 kB 0<none> <none> a0971c4015c1 6 minutes ago 11 MB 11 MB 0 B 0alpine latest 4e38e38c8ce0 9 weeks ago 4.799 MB 0 B 4.799 MB 1alpine 3.3 47cf20d8c26c 9 weeks ago 4.797 MB 4.797 MB 0 B 1Containers space usage:CONTAINER ID IMAGE COMMAND LOCAL VOLUMES SIZE CREATED STATUS NAMES 4a7f7eebae0f alpine:latest "sh" 1 0 B 16 minutes ago Exited (0) 5 minutes ago hopeful_yalow f98f9c2aa1ea alpine:3.3 "sh" 1 212 B 16 minutes ago Exited (0) 48 seconds ago anon-vol Local Volumes space usage:NAME LINKS SIZE 07c7bdf3e34ab76d921894c2b834f073721fccfbbcba792aa7648e3a7a664c2e 2 36 B my-named-vol 0 0 B
SHARED SIZE
是圖像與另一個圖像共享的空間量(即它們的公共數(shù)據(jù))
UNIQUE SIZE
是僅由給定圖像使用的空間量
SIZE
是圖像的虛擬大小,它是的總和SHARED SIZE
與UNIQUE SIZE
注意:網(wǎng)絡信息未顯示,因為它不占用磁盤空間。
health_status
kill
oom
pause
rename
resize
restart
start
stop
top
unpause
update
Docker圖像報告了以下事件:
delete
import
load
pull
push
save
tag
untag
Docker插件報告下列事件:
install
enable
disable
remove
Docker卷報告了下列事件:
create
mount
unmount
destroy
Docker網(wǎng)絡報告了下列事件:
create
connect
disconnect
destroy
Docker守護進程報告下列事件:
reload
的--since
和--until
參數(shù)可以是Unix的時間戳,日期格式時間戳,或持續(xù)時間的字符串(例如去10m
,1h30m
)來計算相對于客戶機的時間。如果您不提供該--since
選項,則該命令僅返回新事件和/或現(xiàn)場事件。支持的格式為日期格式時間戳包括RFC3339Nano,RFC3339, ,2006-01-02T15:04:05
,2006-01-02T15:04:05.999999999
,2006-01-02Z07:00
和2006-01-02
。如果您不提供a Z
或a ,客戶端將使用本地時區(qū)+-00:00
時間戳結束時的時區(qū)偏移量。在提供Unix時間戳時,輸入seconds [.nanoseconds],其中seconds是自1970年1月1日(午夜UTC / GMT)以來經過的秒數(shù),不包括閏秒(又名Unix時代或Unix時間)和可選項。納秒字段是一秒不到9位數(shù)字的一小部分。
過濾標志(-f
或--filter
)格式為“key = value”。如果你想使用多個過濾器,傳遞多個標志(例如 --filter "foo=bar" --filter "bif=baz"
)
多次使用相同的過濾器將作為OR處理; 例如--filter container=588a23dac085 --filter container=a8f7720b8c22
將顯示容器588a23dac085 或容器a8f7720b8c22的事件
使用多個過濾器將作為AND處理; 例如--filter container=588a23dac085 --filter event=start
將顯示事件容器容器588a23dac085 與事件類型是開始
目前支持的過濾器是:
容器(container=<name or id>
)
守護進程(daemon=<name or id>
)
事件(event=<event action>
)
圖像 (image=<tag or id>
)
標簽 (label=<key>
or label=<key>=<value>
)
網(wǎng)絡 (network=<name or id>
)
插件 (plugin=<name or id>
)
類型 (type=<container or image or volume or network or daemon or plugin>
)
體積 (volume=<name or id>
)
如果格式 (--format
) 指定,則將執(zhí)行給定的模板,而不是默認格式。Go的文本/模板包描述格式的所有細節(jié)。
如果格式設置為{{json .}}
事件作為有效的JSON行流。有關JSON行的信息,請參閱http://jsonlines.org/.
對于這個例子,您需要兩個shell。
shell 1:偵聽事件:
$ docker system events
外殼2:啟動和停止容器:
$ docker create --name test alpine:latest top $ docker start test $ docker stop test
shell 1:(再次 .. 現(xiàn)在展示事件):
2017-01-05T00:35:58.859401177+08:00 container create 0fdb48addc82871eb34eb23a847cfd033dedd1a0a37bef2e6d9eb3870fc7ff37 (image=alpine:latest, name=test)2017-01-05T00:36:04.703631903+08:00 network connect e2e1f5ceda09d4300f3a846f0acfaa9a8bb0d89e775eb744c5acecd60e0529e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
退出docker system events
命令,使用CTRL+C
...
您可以使用以下不同的時間語法,通過絕對時間戳或主機上的相對時間過濾輸出:
$ docker system events --since 14832838042017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)$ docker system events --since '2017-01-05'2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)$ docker system events --since '2013-09-03T15:49:29'2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)$ docker system events --since '10m'2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
下面的命令顯示了幾種篩選docker event
輸出。
$ docker system events --filter 'event=stop'2017-01-05T00:40:22.880175420+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)2017-01-05T00:41:17.888104182+08:00 container stop 2a8f...4e78 (image=alpine, name=kickass_brattain)$ docker system events --filter 'image=alpine'2017-01-05T00:41:55.784240236+08:00 container create d9cd...4d70 (image=alpine, name=happy_meitner)2017-01-05T00:41:55.913156783+08:00 container start d9cd...4d70 (image=alpine, name=happy_meitner)2017-01-05T00:42:01.106875249+08:00 container kill d9cd...4d70 (image=alpine, name=happy_meitner, signal=15)2017-01-05T00:42:11.111934041+08:00 container kill d9cd...4d70 (image=alpine, name=happy_meitner, signal=9)2017-01-05T00:42:11.119578204+08:00 container die d9cd...4d70 (exitCode=137, image=alpine, name=happy_meitner)2017-01-05T00:42:11.173276611+08:00 container stop d9cd...4d70 (image=alpine, name=happy_meitner)$ docker system events --filter 'container=test'2017-01-05T00:43:00.139719934+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)2017-01-05T00:43:09.259951086+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)2017-01-05T00:43:09.270102715+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)2017-01-05T00:43:09.312556440+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)$ docker system events --filter 'container=test' --filter 'container=d9cdb1525ea8'2017-01-05T00:44:11.517071981+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)2017-01-05T00:44:17.685870901+08:00 container start d9cd...4d70 (image=alpine, name=happy_meitner)2017-01-05T00:44:29.757658470+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=9)2017-01-05T00:44:29.767718510+08:00 container die 0fdb...ff37 (exitCode=137, image=alpine:latest, name=test)2017-01-05T00:44:29.815798344+08:00 container destroy 0fdb...ff37 (image=alpine:latest, name=test)$ docker system events --filter 'container=test' --filter 'event=stop'2017-01-05T00:46:13.664099505+08:00 container stop a9d1...e130 (image=alpine, name=test)$ docker system events --filter 'type=volume'2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local)2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562f...5025, destination=/foo, driver=local, propagation=rprivate)2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562f...5025, driver=local)2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local)$ docker system events --filter 'type=network'2015-12-23T21:38:24.705709133Z network create 8b11...2c5b (name=test-event-network-local, type=bridge)2015-12-23T21:38:25.119625123Z network connect 8b11...2c5b (name=test-event-network-local, container=b4be...c54e, type=bridge)$ docker system events --filter 'container=container_1' --filter 'container=container_2'2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (imager=redis:2.8)2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)$ docker system events --filter 'type=volume'2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local)2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, destination=/foo, driver=local, propagation=rprivate)2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, driver=local)2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local)$ docker system events --filter 'type=network'2015-12-23T21:38:24.705709133Z network create 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, type=bridge)2015-12-23T21:38:25.119625123Z network connect 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, container=b4be644031a3d90b400f88ab3d4bdf4dc23adb250e696b6328b85441abe2c54e, type=bridge)$ docker system events --filter 'type=plugin'2016-07-25T17:30:14.825557616Z plugin pull ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest)2016-07-25T17:30:14.888127370Z plugin enable ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest)
$ docker system events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}'Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 Type=container Status=attach ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 Type=container Status=start ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 Type=container Status=resize ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 Type=container Status=die ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
$ docker system events --format '{{json .}}' {"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. {"status":"attach","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. {"Type":"network","Action":"connect","Actor":{"ID":"1b50a5bf755f6021dfa78e.. {"status":"start","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f42.. {"status":"resize","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..