github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/docs/reference/commandline/events.md (about) 1 --- 2 title: "events" 3 description: "The events command description and usage" 4 keywords: "events, container, report" 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. 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 # events 17 18 ```markdown 19 Usage: docker 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 Docker containers report the following events: 32 33 attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, health_status, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update 34 35 Docker images report the following events: 36 37 delete, import, load, pull, push, save, tag, untag 38 39 Docker plugins report the following events: 40 41 install, enable, disable, remove 42 43 Docker volumes report the following events: 44 45 create, mount, unmount, destroy 46 47 Docker networks report the following events: 48 49 create, connect, disconnect, destroy 50 51 Docker daemon report the following events: 52 53 reload 54 55 The `--since` and `--until` parameters can be Unix timestamps, date formatted 56 timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed 57 relative to the client machine’s time. If you do not provide the `--since` option, 58 the command returns only new and/or live events. Supported formats for date 59 formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`, 60 `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local 61 timezone on the client will be used if you do not provide either a `Z` or a 62 `+-00:00` timezone offset at the end of the timestamp. When providing Unix 63 timestamps enter seconds[.nanoseconds], where seconds is the number of seconds 64 that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap 65 seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a 66 fraction of a second no more than nine digits long. 67 68 ## Filtering 69 70 The filtering flag (`-f` or `--filter`) format is of "key=value". If you would 71 like to use multiple filters, pass multiple flags (e.g., 72 `--filter "foo=bar" --filter "bif=baz"`) 73 74 Using the same filter multiple times will be handled as a *OR*; for example 75 `--filter container=588a23dac085 --filter container=a8f7720b8c22` will display 76 events for container 588a23dac085 *OR* container a8f7720b8c22 77 78 Using multiple filters will be handled as a *AND*; for example 79 `--filter container=588a23dac085 --filter event=start` will display events for 80 container container 588a23dac085 *AND* the event type is *start* 81 82 The currently supported filters are: 83 84 * container (`container=<name or id>`) 85 * event (`event=<event action>`) 86 * image (`image=<tag or id>`) 87 * plugin (experimental) (`plugin=<name or id>`) 88 * label (`label=<key>` or `label=<key>=<value>`) 89 * type (`type=<container or image or volume or network or daemon>`) 90 * volume (`volume=<name or id>`) 91 * network (`network=<name or id>`) 92 * daemon (`daemon=<name or id>`) 93 94 ## Format 95 96 If a format (`--format`) is specified, the given template will be executed 97 instead of the default 98 format. Go's [text/template](http://golang.org/pkg/text/template/) package 99 describes all the details of the format. 100 101 If a format is set to `{{json .}}`, the events are streamed as valid JSON 102 Lines. For information about JSON Lines, please refer to http://jsonlines.org/ . 103 104 ## Examples 105 106 You'll need two shells for this example. 107 108 **Shell 1: Listening for events:** 109 110 $ docker events 111 112 **Shell 2: Start and Stop containers:** 113 114 $ docker start 4386fb97867d 115 $ docker stop 4386fb97867d 116 $ docker stop 7805c1d35632 117 118 **Shell 1: (Again .. now showing events):** 119 120 2015-05-12T11:51:30.999999999Z07:00 container start 4386fb97867d (image=ubuntu-1:14.04) 121 2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 122 2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 123 2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 124 2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 125 126 **Show events in the past from a specified time:** 127 128 $ docker events --since 1378216169 129 2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 130 2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 131 2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 132 2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 133 134 $ docker events --since '2013-09-03' 135 2015-05-12T11:51:30.999999999Z07:00 container start 4386fb97867d (image=ubuntu-1:14.04) 136 2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 137 2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 138 2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 139 2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 140 141 $ docker events --since '2013-09-03T15:49:29' 142 2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 143 2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 144 2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 145 2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 146 147 This example outputs all events that were generated in the last 3 minutes, 148 relative to the current time on the client machine: 149 150 $ docker events --since '3m' 151 2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 152 2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 153 2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 154 2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 155 156 **Filter events:** 157 158 $ docker events --filter 'event=stop' 159 2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 160 2014-09-03T17:42:14.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 161 162 $ docker events --filter 'image=ubuntu-1:14.04' 163 2014-05-10T17:42:14.999999999Z07:00 container start 4386fb97867d (image=ubuntu-1:14.04) 164 2014-05-10T17:42:14.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 165 2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 166 167 $ docker events --filter 'container=7805c1d35632' 168 2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 169 2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image= redis:2.8) 170 171 $ docker events --filter 'container=7805c1d35632' --filter 'container=4386fb97867d' 172 2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 173 2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 174 2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 175 2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 176 177 $ docker events --filter 'container=7805c1d35632' --filter 'event=stop' 178 2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 179 180 $ docker events --filter 'container=container_1' --filter 'container=container_2' 181 2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 182 2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 183 2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (imager=redis:2.8) 184 2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 185 186 $ docker events --filter 'type=volume' 187 2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local) 188 2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, destination=/foo, driver=local, propagation=rprivate) 189 2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, driver=local) 190 2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local) 191 192 $ docker events --filter 'type=network' 193 2015-12-23T21:38:24.705709133Z network create 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, type=bridge) 194 2015-12-23T21:38:25.119625123Z network connect 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, container=b4be644031a3d90b400f88ab3d4bdf4dc23adb250e696b6328b85441abe2c54e, type=bridge) 195 196 $ docker events --filter 'type=plugin' (experimental) 197 2016-07-25T17:30:14.825557616Z plugin pull ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest) 198 2016-07-25T17:30:14.888127370Z plugin enable ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest) 199 200 **Format:** 201 202 $ docker events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}' 203 Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 204 Type=container Status=attach ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 205 Type=container Status=start ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 206 Type=container Status=resize ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 207 Type=container Status=die ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 208 Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 209 210 **Format (as JSON Lines):** 211 212 $ docker events --format '{{json .}}' 213 {"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. 214 {"status":"attach","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. 215 {"Type":"network","Action":"connect","Actor":{"ID":"1b50a5bf755f6021dfa78e.. 216 {"status":"start","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f42.. 217 {"status":"resize","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..