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