github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/system_events.md (about) 1 --- 2 title: "system events" 3 description: "The system events command description and usage" 4 keywords: "system, events, container, report" 5 --- 6 7 <!-- This file is maintained within the docker/cli GitHub 8 repository at https://github.com/docker/cli/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # system events 17 18 ```markdown 19 Usage: docker system events [OPTIONS] 20 21 Get real time events from the server 22 23 Options: 24 -f, --filter value Filter output based on conditions provided (default []) 25 --format string Format the output using the given Go template 26 --help Print usage 27 --since string Show all events created since timestamp 28 --until string Stream events until this timestamp 29 ``` 30 31 ## Description 32 33 Use `docker system events` to get real-time events from the server. These 34 events differ per Docker object type. 35 36 ### Object types 37 38 #### Containers 39 40 Docker containers report the following events: 41 42 - `attach` 43 - `commit` 44 - `copy` 45 - `create` 46 - `destroy` 47 - `detach` 48 - `die` 49 - `exec_create` 50 - `exec_detach` 51 - `exec_start` 52 - `export` 53 - `health_status` 54 - `kill` 55 - `oom` 56 - `pause` 57 - `rename` 58 - `resize` 59 - `restart` 60 - `start` 61 - `stop` 62 - `top` 63 - `unpause` 64 - `update` 65 66 #### Images 67 68 Docker images report the following events: 69 70 - `delete` 71 - `import` 72 - `load` 73 - `pull` 74 - `push` 75 - `save` 76 - `tag` 77 - `untag` 78 79 #### Plugins 80 81 Docker plugins report the following events: 82 83 - `install` 84 - `enable` 85 - `disable` 86 - `remove` 87 88 #### Volumes 89 90 Docker volumes report the following events: 91 92 - `create` 93 - `mount` 94 - `unmount` 95 - `destroy` 96 97 #### Networks 98 99 Docker networks report the following events: 100 101 - `create` 102 - `connect` 103 - `disconnect` 104 - `destroy` 105 106 #### Daemons 107 108 Docker daemons report the following events: 109 110 - `reload` 111 112 ### Limiting, filtering, and formatting the output 113 114 #### Limit events by time 115 116 The `--since` and `--until` parameters can be Unix timestamps, date formatted 117 timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed 118 relative to the client machine’s time. If you do not provide the `--since` option, 119 the command returns only new and/or live events. Supported formats for date 120 formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`, 121 `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local 122 timezone on the client will be used if you do not provide either a `Z` or a 123 `+-00:00` timezone offset at the end of the timestamp. When providing Unix 124 timestamps enter seconds[.nanoseconds], where seconds is the number of seconds 125 that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap 126 seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a 127 fraction of a second no more than nine digits long. 128 129 #### Filtering 130 131 The filtering flag (`-f` or `--filter`) format is of "key=value". If you would 132 like to use multiple filters, pass multiple flags (e.g., 133 `--filter "foo=bar" --filter "bif=baz"`) 134 135 Using the same filter multiple times will be handled as a *OR*; for example 136 `--filter container=588a23dac085 --filter container=a8f7720b8c22` will display 137 events for container 588a23dac085 *OR* container a8f7720b8c22 138 139 Using multiple filters will be handled as a *AND*; for example 140 `--filter container=588a23dac085 --filter event=start` will display events for 141 container container 588a23dac085 *AND* the event type is *start* 142 143 The currently supported filters are: 144 145 * container (`container=<name or id>`) 146 * daemon (`daemon=<name or id>`) 147 * event (`event=<event action>`) 148 * image (`image=<tag or id>`) 149 * label (`label=<key>` or `label=<key>=<value>`) 150 * network (`network=<name or id>`) 151 * plugin (`plugin=<name or id>`) 152 * type (`type=<container or image or volume or network or daemon or plugin>`) 153 * volume (`volume=<name or id>`) 154 155 #### Format 156 157 If a format (`--format`) is specified, the given template will be executed 158 instead of the default 159 format. Go's [text/template](http://golang.org/pkg/text/template/) package 160 describes all the details of the format. 161 162 If a format is set to `{{json .}}`, the events are streamed as valid JSON 163 Lines. For information about JSON Lines, please refer to http://jsonlines.org/ . 164 165 ## Examples 166 167 ### Basic example 168 169 You'll need two shells for this example. 170 171 **Shell 1: Listening for events:** 172 173 ```bash 174 $ docker system events 175 ``` 176 177 **Shell 2: Start and Stop containers:** 178 179 ```bash 180 $ docker create --name test alpine:latest top 181 $ docker start test 182 $ docker stop test 183 ``` 184 185 **Shell 1: (Again .. now showing events):** 186 187 ```none 188 2017-01-05T00:35:58.859401177+08:00 container create 0fdb48addc82871eb34eb23a847cfd033dedd1a0a37bef2e6d9eb3870fc7ff37 (image=alpine:latest, name=test) 189 2017-01-05T00:36:04.703631903+08:00 network connect e2e1f5ceda09d4300f3a846f0acfaa9a8bb0d89e775eb744c5acecd60e0529e2 (container=0fdb...ff37, name=bridge, type=bridge) 190 2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test) 191 2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15) 192 2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test) 193 2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 194 2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test) 195 ``` 196 197 To exit the `docker system events` command, use `CTRL+C`. 198 199 ### Filter events by time 200 201 You can filter the output by an absolute timestamp or relative time on the host 202 machine, using the following different time syntaxes: 203 204 ```bash 205 $ docker system events --since 1483283804 206 2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local) 207 2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test) 208 2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 209 2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test) 210 2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15) 211 2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test) 212 2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 213 2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test) 214 215 $ docker system events --since '2017-01-05' 216 2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local) 217 2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test) 218 2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 219 2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test) 220 2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15) 221 2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test) 222 2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 223 2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test) 224 225 $ docker system events --since '2013-09-03T15:49:29' 226 2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local) 227 2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test) 228 2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 229 2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test) 230 2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15) 231 2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test) 232 2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 233 2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test) 234 235 $ docker system events --since '10m' 236 2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local) 237 2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test) 238 2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 239 2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test) 240 2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15) 241 2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test) 242 2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge) 243 2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test) 244 ``` 245 246 ### Filter events by criteria 247 248 The following commands show several different ways to filter the `docker event` 249 output. 250 251 ```bash 252 $ docker system events --filter 'event=stop' 253 254 2017-01-05T00:40:22.880175420+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test) 255 2017-01-05T00:41:17.888104182+08:00 container stop 2a8f...4e78 (image=alpine, name=kickass_brattain) 256 257 $ docker system events --filter 'image=alpine' 258 259 2017-01-05T00:41:55.784240236+08:00 container create d9cd...4d70 (image=alpine, name=happy_meitner) 260 2017-01-05T00:41:55.913156783+08:00 container start d9cd...4d70 (image=alpine, name=happy_meitner) 261 2017-01-05T00:42:01.106875249+08:00 container kill d9cd...4d70 (image=alpine, name=happy_meitner, signal=15) 262 2017-01-05T00:42:11.111934041+08:00 container kill d9cd...4d70 (image=alpine, name=happy_meitner, signal=9) 263 2017-01-05T00:42:11.119578204+08:00 container die d9cd...4d70 (exitCode=137, image=alpine, name=happy_meitner) 264 2017-01-05T00:42:11.173276611+08:00 container stop d9cd...4d70 (image=alpine, name=happy_meitner) 265 266 $ docker system events --filter 'container=test' 267 268 2017-01-05T00:43:00.139719934+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test) 269 2017-01-05T00:43:09.259951086+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15) 270 2017-01-05T00:43:09.270102715+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test) 271 2017-01-05T00:43:09.312556440+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test) 272 273 $ docker system events --filter 'container=test' --filter 'container=d9cdb1525ea8' 274 275 2017-01-05T00:44:11.517071981+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test) 276 2017-01-05T00:44:17.685870901+08:00 container start d9cd...4d70 (image=alpine, name=happy_meitner) 277 2017-01-05T00:44:29.757658470+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=9) 278 2017-01-05T00:44:29.767718510+08:00 container die 0fdb...ff37 (exitCode=137, image=alpine:latest, name=test) 279 2017-01-05T00:44:29.815798344+08:00 container destroy 0fdb...ff37 (image=alpine:latest, name=test) 280 281 $ docker system events --filter 'container=test' --filter 'event=stop' 282 283 2017-01-05T00:46:13.664099505+08:00 container stop a9d1...e130 (image=alpine, name=test) 284 285 $ docker system events --filter 'type=volume' 286 287 2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local) 288 2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562f...5025, destination=/foo, driver=local, propagation=rprivate) 289 2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562f...5025, driver=local) 290 2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local) 291 292 $ docker system events --filter 'type=network' 293 294 2015-12-23T21:38:24.705709133Z network create 8b11...2c5b (name=test-event-network-local, type=bridge) 295 2015-12-23T21:38:25.119625123Z network connect 8b11...2c5b (name=test-event-network-local, container=b4be...c54e, type=bridge) 296 297 $ docker system events --filter 'container=container_1' --filter 'container=container_2' 298 299 2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 300 2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 301 2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (imager=redis:2.8) 302 2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 303 304 $ docker system events --filter 'type=volume' 305 306 2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local) 307 2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, destination=/foo, driver=local, propagation=rprivate) 308 2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, driver=local) 309 2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local) 310 311 $ docker system events --filter 'type=network' 312 313 2015-12-23T21:38:24.705709133Z network create 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, type=bridge) 314 2015-12-23T21:38:25.119625123Z network connect 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, container=b4be644031a3d90b400f88ab3d4bdf4dc23adb250e696b6328b85441abe2c54e, type=bridge) 315 316 $ docker system events --filter 'type=plugin' 317 318 2016-07-25T17:30:14.825557616Z plugin pull ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest) 319 2016-07-25T17:30:14.888127370Z plugin enable ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest) 320 ``` 321 322 ### Format the output 323 324 ```bash 325 $ docker system events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}' 326 327 Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 328 Type=container Status=attach ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 329 Type=container Status=start ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 330 Type=container Status=resize ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 331 Type=container Status=die ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 332 Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 333 ``` 334 335 #### Format as JSON 336 337 ```none 338 $ docker system events --format '{{json .}}' 339 340 {"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. 341 {"status":"attach","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. 342 {"Type":"network","Action":"connect","Actor":{"ID":"1b50a5bf755f6021dfa78e.. 343 {"status":"start","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f42.. 344 {"status":"resize","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. 345 ```