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