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