github.com/45cali/docker@v1.11.1/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      Usage: docker events [OPTIONS]
    14  
    15      Get real time events from the server
    16  
    17        -f, --filter=[]    Filter output based on conditions provided
    18        --help             Print usage
    19        --since=""         Show all events created since timestamp
    20        --until=""         Stream events until this timestamp
    21  
    22  Docker containers report the following events:
    23  
    24      attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
    25  
    26  Docker images report the following events:
    27  
    28      delete, import, pull, push, tag, untag
    29  
    30  Docker volumes report the following events:
    31  
    32      create, mount, unmount, destroy
    33  
    34  Docker networks report the following events:
    35  
    36      create, connect, disconnect, destroy
    37  
    38  The `--since` and `--until` parameters can be Unix timestamps, date formatted
    39  timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
    40  relative to the client machine’s time. If you do not provide the `--since` option,
    41  the command returns only new and/or live events.  Supported formats for date
    42  formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`,
    43  `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
    44  timezone on the client will be used if you do not provide either a `Z` or a
    45  `+-00:00` timezone offset at the end of the timestamp.  When providing Unix
    46  timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
    47  that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
    48  seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
    49  fraction of a second no more than nine digits long.
    50  
    51  ## Filtering
    52  
    53  The filtering flag (`-f` or `--filter`) format is of "key=value". If you would
    54  like to use multiple filters, pass multiple flags (e.g.,
    55  `--filter "foo=bar" --filter "bif=baz"`)
    56  
    57  Using the same filter multiple times will be handled as a *OR*; for example
    58  `--filter container=588a23dac085 --filter container=a8f7720b8c22` will display
    59  events for container 588a23dac085 *OR* container a8f7720b8c22
    60  
    61  Using multiple filters will be handled as a *AND*; for example
    62  `--filter container=588a23dac085 --filter event=start` will display events for
    63  container container 588a23dac085 *AND* the event type is *start*
    64  
    65  The currently supported filters are:
    66  
    67  * container (`container=<name or id>`)
    68  * event (`event=<event action>`)
    69  * image (`image=<tag or id>`)
    70  * label (`label=<key>` or `label=<key>=<value>`)
    71  * type (`type=<container or image or volume or network>`)
    72  * volume (`volume=<name or id>`)
    73  * network (`network=<name or id>`)
    74  
    75  ## Examples
    76  
    77  You'll need two shells for this example.
    78  
    79  **Shell 1: Listening for events:**
    80  
    81      $ docker events
    82  
    83  **Shell 2: Start and Stop containers:**
    84  
    85      $ docker start 4386fb97867d
    86      $ docker stop 4386fb97867d
    87      $ docker stop 7805c1d35632
    88  
    89  **Shell 1: (Again .. now showing events):**
    90  
    91      2015-05-12T11:51:30.999999999Z07:00 container start 4386fb97867d (image=ubuntu-1:14.04)
    92      2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
    93      2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
    94      2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8)
    95      2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
    96  
    97  **Show events in the past from a specified time:**
    98  
    99      $ docker events --since 1378216169
   100      2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
   101      2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
   102      2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8)
   103      2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
   104  
   105      $ docker events --since '2013-09-03'
   106      2015-05-12T11:51:30.999999999Z07:00 container start 4386fb97867d (image=ubuntu-1:14.04)
   107      2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
   108      2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
   109      2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8)
   110      2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
   111  
   112      $ docker events --since '2013-09-03T15:49:29'
   113      2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
   114      2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
   115      2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8)
   116      2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
   117  
   118  This example outputs all events that were generated in the last 3 minutes,
   119  relative to the current time on the client machine:
   120  
   121      $ docker events --since '3m'
   122      2015-05-12T11:51:30.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
   123      2015-05-12T15:52:12.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
   124      2015-05-12T15:53:45.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8)
   125      2015-05-12T15:54:03.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
   126  
   127  **Filter events:**
   128  
   129      $ docker events --filter 'event=stop'
   130      2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
   131      2014-09-03T17:42:14.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
   132  
   133      $ docker events --filter 'image=ubuntu-1:14.04'
   134      2014-05-10T17:42:14.999999999Z07:00 container start 4386fb97867d (image=ubuntu-1:14.04)
   135      2014-05-10T17:42:14.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
   136      2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
   137  
   138      $ docker events --filter 'container=7805c1d35632'
   139      2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8)
   140      2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image= redis:2.8)
   141  
   142      $ docker events --filter 'container=7805c1d35632' --filter 'container=4386fb97867d'
   143      2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
   144      2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
   145      2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (image=redis:2.8)
   146      2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
   147  
   148      $ docker events --filter 'container=7805c1d35632' --filter 'event=stop'
   149      2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
   150  
   151      $ docker events --filter 'container=container_1' --filter 'container=container_2'
   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 (imager=redis:2.8)
   155      2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
   156  
   157      $ docker events --filter 'type=volume'
   158      2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local)
   159      2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, destination=/foo, driver=local, propagation=rprivate)
   160      2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, driver=local)
   161      2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local)
   162  
   163      $ docker events --filter 'type=network'
   164      2015-12-23T21:38:24.705709133Z network create 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, type=bridge)
   165      2015-12-23T21:38:25.119625123Z network connect 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, container=b4be644031a3d90b400f88ab3d4bdf4dc23adb250e696b6328b85441abe2c54e, type=bridge)