gitee.com/bomy/docker.git@v1.13.1/man/docker-events.1.md (about) 1 % DOCKER(1) Docker User Manuals 2 % Docker Community 3 % JUNE 2014 4 # NAME 5 docker-events - Get real time events from the server 6 7 # SYNOPSIS 8 **docker events** 9 [**--help**] 10 [**-f**|**--filter**[=*[]*]] 11 [**--since**[=*SINCE*]] 12 [**--until**[=*UNTIL*]] 13 [**--format**[=*FORMAT*]] 14 15 16 # DESCRIPTION 17 Get event information from the Docker daemon. Information can include historical 18 information and real-time information. 19 20 Docker containers will report the following events: 21 22 attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update 23 24 Docker images report the following events: 25 26 delete, import, load, pull, push, save, tag, untag 27 28 Docker volumes report the following events: 29 30 create, mount, unmount, destroy 31 32 Docker networks report the following events: 33 34 create, connect, disconnect, destroy 35 36 # OPTIONS 37 **--help** 38 Print usage statement 39 40 **-f**, **--filter**=[] 41 Filter output based on these conditions 42 - container (`container=<name or id>`) 43 - event (`event=<event action>`) 44 - image (`image=<tag or id>`) 45 - plugin (experimental) (`plugin=<name or id>`) 46 - label (`label=<key>` or `label=<key>=<value>`) 47 - type (`type=<container or image or volume or network or daemon>`) 48 - volume (`volume=<name or id>`) 49 - network (`network=<name or id>`) 50 - daemon (`daemon=<name or id>`) 51 52 **--since**="" 53 Show all events created since timestamp 54 55 **--until**="" 56 Stream events until this timestamp 57 58 **--format**="" 59 Format the output using the given Go template 60 61 The `--since` and `--until` parameters can be Unix timestamps, date formatted 62 timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed 63 relative to the client machine's time. If you do not provide the `--since` option, 64 the command returns only new and/or live events. Supported formats for date 65 formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`, 66 `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local 67 timezone on the client will be used if you do not provide either a `Z` or a 68 `+-00:00` timezone offset at the end of the timestamp. When providing Unix 69 timestamps enter seconds[.nanoseconds], where seconds is the number of seconds 70 that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap 71 seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a 72 fraction of a second no more than nine digits long. 73 74 # EXAMPLES 75 76 ## Listening for Docker events 77 78 After running docker events a container 786d698004576 is started and stopped 79 (The container name has been shortened in the output below): 80 81 # docker events 82 2015-01-28T20:21:31.000000000-08:00 59211849bc10: (from whenry/testimage:latest) start 83 2015-01-28T20:21:31.000000000-08:00 59211849bc10: (from whenry/testimage:latest) die 84 2015-01-28T20:21:32.000000000-08:00 59211849bc10: (from whenry/testimage:latest) stop 85 86 ## Listening for events since a given date 87 Again the output container IDs have been shortened for the purposes of this document: 88 89 # docker events --since '2015-01-28' 90 2015-01-28T20:25:38.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) create 91 2015-01-28T20:25:38.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) start 92 2015-01-28T20:25:39.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) create 93 2015-01-28T20:25:39.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) start 94 2015-01-28T20:25:40.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) die 95 2015-01-28T20:25:42.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) stop 96 2015-01-28T20:25:45.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) start 97 2015-01-28T20:25:45.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) die 98 2015-01-28T20:25:46.000000000-08:00 c21f6c22ba27: (from whenry/testimage:latest) stop 99 100 The following example outputs all events that were generated in the last 3 minutes, 101 relative to the current time on the client machine: 102 103 # docker events --since '3m' 104 2015-05-12T11:51:30.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die 105 2015-05-12T15:52:12.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop 106 2015-05-12T15:53:45.999999999Z07:00 7805c1d35632: (from redis:2.8) die 107 2015-05-12T15:54:03.999999999Z07:00 7805c1d35632: (from redis:2.8) stop 108 109 If you do not provide the --since option, the command returns only new and/or 110 live events. 111 112 ## Format 113 114 If a format (`--format`) is specified, the given template will be executed 115 instead of the default format. Go's **text/template** package describes all the 116 details of the format. 117 118 # docker events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}' 119 Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 120 Type=container Status=attach ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 121 Type=container Status=start ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 122 Type=container Status=resize ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 123 Type=container Status=die ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 124 Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 125 126 If a format is set to `{{json .}}`, the events are streamed as valid JSON 127 Lines. For information about JSON Lines, please refer to http://jsonlines.org/ . 128 129 # docker events --format '{{json .}}' 130 {"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. 131 {"status":"attach","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. 132 {"Type":"network","Action":"connect","Actor":{"ID":"1b50a5bf755f6021dfa78e.. 133 {"status":"start","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f42.. 134 {"status":"resize","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. 135 136 ## Filters 137 138 $ docker events --filter 'event=stop' 139 2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 140 2014-09-03T17:42:14.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 141 142 $ docker events --filter 'image=ubuntu-1:14.04' 143 2014-05-10T17:42:14.999999999Z07:00 container start 4386fb97867d (image=ubuntu-1:14.04) 144 2014-05-10T17:42:14.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 145 2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 146 147 $ docker events --filter 'container=7805c1d35632' 148 2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 149 2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image= redis:2.8) 150 151 $ docker events --filter 'container=7805c1d35632' --filter 'container=4386fb97867d' 152 2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04) 153 2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04) 154 2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8) 155 2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 156 157 $ docker events --filter 'container=7805c1d35632' --filter 'event=stop' 158 2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8) 159 160 $ docker events --filter 'type=volume' 161 2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local) 162 2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, destination=/foo, driver=local, propagation=rprivate) 163 2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, driver=local) 164 2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local) 165 166 $ docker events --filter 'type=network' 167 2015-12-23T21:38:24.705709133Z network create 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, type=bridge) 168 2015-12-23T21:38:25.119625123Z network connect 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, container=b4be644031a3d90b400f88ab3d4bdf4dc23adb250e696b6328b85441abe2c54e, type=bridge) 169 170 $ docker events --filter 'type=plugin' (experimental) 171 2016-07-25T17:30:14.825557616Z plugin pull ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest) 172 2016-07-25T17:30:14.888127370Z plugin enable ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest) 173 174 175 # HISTORY 176 April 2014, Originally compiled by William Henry (whenry at redhat dot com) 177 based on docker.com source material and internal work. 178 June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au> 179 June 2015, updated by Brian Goff <cpuguy83@gmail.com> 180 October 2015, updated by Mike Brown <mikebrow@gmail.com>