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