github.com/slene/docker@v1.8.0-rc1/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  weight=1
     9  +++
    10  <![end-metadata]-->
    11  
    12  # events
    13  
    14      Usage: docker events [OPTIONS]
    15  
    16      Get real time events from the server
    17  
    18        -f, --filter=[]    Filter output based on conditions provided
    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      create, destroy, die, export, kill, oom, pause, restart, start, stop, unpause
    25  
    26  and Docker images will report:
    27  
    28      untag, delete
    29  
    30  The `--since` and `--until` parameters can be Unix timestamps, RFC3339
    31  dates or Go duration strings (e.g. `10m`, `1h30m`) computed relative to
    32  client machine’s time. If you do not provide the --since option, the command
    33  returns only new and/or live events.
    34  
    35  ## Filtering
    36  
    37  The filtering flag (`-f` or `--filter`) format is of "key=value". If you would
    38  like to use multiple filters, pass multiple flags (e.g., 
    39  `--filter "foo=bar" --filter "bif=baz"`)
    40  
    41  Using the same filter multiple times will be handled as a *OR*; for example
    42  `--filter container=588a23dac085 --filter container=a8f7720b8c22` will display
    43  events for container 588a23dac085 *OR* container a8f7720b8c22
    44  
    45  Using multiple filters will be handled as a *AND*; for example
    46  `--filter container=588a23dac085 --filter event=start` will display events for
    47  container container 588a23dac085 *AND* the event type is *start*
    48  
    49  The currently supported filters are:
    50  
    51  * container
    52  * event
    53  * image
    54  
    55  ## Examples
    56  
    57  You'll need two shells for this example.
    58  
    59  **Shell 1: Listening for events:**
    60  
    61      $ docker events
    62  
    63  **Shell 2: Start and Stop containers:**
    64  
    65      $ docker start 4386fb97867d
    66      $ docker stop 4386fb97867d
    67      $ docker stop 7805c1d35632
    68  
    69  **Shell 1: (Again .. now showing events):**
    70  
    71      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
    72      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
    73      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
    74      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
    75      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
    76  
    77  **Show events in the past from a specified time:**
    78  
    79      $ docker events --since 1378216169
    80      2014-03-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
    81      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
    82      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
    83      2014-03-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
    84  
    85      $ docker events --since '2013-09-03'
    86      2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
    87      2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
    88      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
    89      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
    90      2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
    91  
    92      $ docker events --since '2013-09-03T15:49:29'
    93      2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
    94      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
    95      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
    96      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
    97  
    98  This example outputs all events that were generated in the last 3 minutes,
    99  relative to the current time on the client machine:
   100  
   101      $ docker events --since '3m'
   102      2015-05-12T11:51:30.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   103      2015-05-12T15:52:12.999999999Z07:00 4 4386fb97867d: (from ubuntu-1:14.04) stop
   104      2015-05-12T15:53:45.999999999Z07:00  7805c1d35632: (from redis:2.8) die
   105      2015-05-12T15:54:03.999999999Z07:00  7805c1d35632: (from redis:2.8) stop
   106  
   107  **Filter events:**
   108  
   109      $ docker events --filter 'event=stop'
   110      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   111      2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   112  
   113      $ docker events --filter 'image=ubuntu-1:14.04'
   114      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
   115      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   116      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   117  
   118      $ docker events --filter 'container=7805c1d35632'
   119      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
   120      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   121  
   122      $ docker events --filter 'container=7805c1d35632' --filter 'container=4386fb97867d'
   123      2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   124      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   125      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
   126      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   127  
   128      $ docker events --filter 'container=7805c1d35632' --filter 'event=stop'
   129      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   130  
   131      $ docker events --filter 'container=container_1' --filter 'container=container_2'
   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