github.com/kim0/docker@v0.6.2-0.20161130212042-4addda3f07e7/docs/reference/commandline/stats.md (about)

     1  ---
     2  title: "stats"
     3  description: "The stats command description and usage"
     4  keywords: ["container, resource, statistics"]
     5  ---
     6  
     7  <!-- This file is maintained within the docker/docker Github
     8       repository at https://github.com/docker/docker/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # stats
    17  
    18  ```markdown
    19  Usage:  docker stats [OPTIONS] [CONTAINER...]
    20  
    21  Display a live stream of container(s) resource usage statistics
    22  
    23  Options:
    24    -a, --all         Show all containers (default shows just running)
    25        --help        Print usage
    26        --no-stream   Disable streaming stats and only pull the first result
    27  ```
    28  
    29  The `docker stats` command returns a live data stream for running containers. To limit data to one or more specific containers, specify a list of container names or ids separated by a space. You can specify a stopped container but stopped containers do not return any data.
    30  
    31  If you want more detailed information about a container's resource usage, use the `/containers/(id)/stats` API endpoint.
    32  
    33  ## Examples
    34  
    35  Running `docker stats` on all running containers against a Linux daemon.
    36  
    37      $ docker stats
    38      CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O
    39      1285939c1fd3        0.07%               796 KiB / 64 MiB        1.21%               788 B / 648 B       3.568 MB / 512 KB
    40      9c76f7834ae2        0.07%               2.746 MiB / 64 MiB      4.29%               1.266 KB / 648 B    12.4 MB / 0 B
    41      d1ea048f04e4        0.03%               4.583 MiB / 64 MiB      6.30%               2.854 KB / 648 B    27.7 MB / 0 B
    42  
    43  Running `docker stats` on multiple containers by name and id against a Linux daemon.
    44  
    45      $ docker stats fervent_panini 5acfcb1b4fd1
    46      CONTAINER           CPU %               MEM USAGE/LIMIT       MEM %               NET I/O
    47      5acfcb1b4fd1        0.00%               115.2 MiB/1.045 GiB   11.03%              1.422 kB/648 B
    48      fervent_panini      0.02%               11.08 MiB/1.045 GiB   1.06%               648 B/648 B
    49  
    50  Running `docker stats` on all running containers against a Windows daemon.
    51  
    52      PS E:\> docker stats
    53      CONTAINER           CPU %               PRIV WORKING SET    NET I/O             BLOCK I/O
    54      09d3bb5b1604        6.61%               38.21 MiB           17.1 kB / 7.73 kB   10.7 MB / 3.57 MB
    55      9db7aa4d986d        9.19%               38.26 MiB           15.2 kB / 7.65 kB   10.6 MB / 3.3 MB
    56      3f214c61ad1d        0.00%               28.64 MiB           64 kB / 6.84 kB     4.42 MB / 6.93 MB
    57  
    58  Running `docker stats` on multiple containers by name and id against a Windows daemon.
    59  
    60      PS E:\> docker ps -a
    61      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    62      3f214c61ad1d        nanoserver          "cmd"               2 minutes ago       Up 2 minutes                            big_minsky
    63      9db7aa4d986d        windowsservercore   "cmd"               2 minutes ago       Up 2 minutes                            mad_wilson
    64      09d3bb5b1604        windowsservercore   "cmd"               2 minutes ago       Up 2 minutes                            affectionate_easley
    65  
    66      PS E:\> docker stats 3f214c61ad1d mad_wilson
    67      CONTAINER           CPU %               PRIV WORKING SET    NET I/O             BLOCK I/O
    68      3f214c61ad1d        0.00%               46.25 MiB           76.3 kB / 7.92 kB   10.3 MB / 14.7 MB
    69      mad_wilson          9.59%               40.09 MiB           27.6 kB / 8.81 kB   17 MB / 20.1 MB
    70  
    71  ## Formatting
    72  
    73  The formatting option (`--format`) pretty prints container output
    74  using a Go template.
    75  
    76  Valid placeholders for the Go template are listed below:
    77  
    78  Placeholder  | Description
    79  ------------ | --------------------------------------------
    80  `.Container` | Container name or ID
    81  `.CPUPerc`   | CPU percentage
    82  `.MemUsage`  | Memory usage
    83  `.NetIO`     | Network IO
    84  `.BlockIO`   | Block IO
    85  `.MemPerc`   | Memory percentage (Not available on Windows)
    86  `.PIDs`      | Number of PIDs (Not available on Windows)
    87  
    88  
    89  When using the `--format` option, the `stats` command either
    90  outputs the data exactly as the template declares or, when using the
    91  `table` directive, includes column headers as well.
    92  
    93  The following example uses a template without headers and outputs the
    94  `Container` and `CPUPerc` entries separated by a colon for all images:
    95  
    96  ```bash
    97  $ docker stats --format "{{.Container}}: {{.CPUPerc}}"
    98  
    99  09d3bb5b1604: 6.61%
   100  9db7aa4d986d: 9.19%
   101  3f214c61ad1d: 0.00%
   102  ```
   103  
   104  To list all containers statistics with their name, CPU percentage and memory
   105  usage in a table format you can use:
   106  
   107  ```bash
   108  $ docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"
   109  
   110  CONTAINER           CPU %               PRIV WORKING SET
   111  1285939c1fd3        0.07%               796 KiB / 64 MiB
   112  9c76f7834ae2        0.07%               2.746 MiB / 64 MiB
   113  d1ea048f04e4        0.03%               4.583 MiB / 64 MiB
   114  ```