github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/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 --format string Pretty-print images using a Go template 26 --help Print usage 27 --no-stream Disable streaming stats and only pull the first result 28 ``` 29 30 ## Description 31 32 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. 33 34 If you want more detailed information about a container's resource usage, use the `/containers/(id)/stats` API endpoint. 35 36 ## Examples 37 38 Running `docker stats` on all running containers against a Linux daemon. 39 40 ```bash 41 $ docker stats 42 CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O 43 1285939c1fd3 0.07% 796 KiB / 64 MiB 1.21% 788 B / 648 B 3.568 MB / 512 KB 44 9c76f7834ae2 0.07% 2.746 MiB / 64 MiB 4.29% 1.266 KB / 648 B 12.4 MB / 0 B 45 d1ea048f04e4 0.03% 4.583 MiB / 64 MiB 6.30% 2.854 KB / 648 B 27.7 MB / 0 B 46 ``` 47 48 Running `docker stats` on multiple containers by name and id against a Linux daemon. 49 50 ```bash 51 $ docker stats fervent_panini 5acfcb1b4fd1 52 CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O 53 5acfcb1b4fd1 0.00% 115.2 MiB/1.045 GiB 11.03% 1.422 kB/648 B 54 fervent_panini 0.02% 11.08 MiB/1.045 GiB 1.06% 648 B/648 B 55 ``` 56 57 Running `docker stats` with customized format on all (Running and Stopped) containers. 58 59 ```bash 60 $ docker stats --all --format "table {{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" 61 CONTAINER ID NAME CPU % MEM USAGE / LIMIT 62 c9dfa83f0317f87637d5b7e67aa4223337d947215c5a9947e697e4f7d3e0f834 ecstatic_noether 0.00% 56KiB / 15.57GiB 63 8f92d01cf3b29b4f5fca4cd33d907e05def7af5a3684711b20a2369d211ec67f stoic_goodall 0.07% 32.86MiB / 15.57GiB 64 38dd23dba00f307d53d040c1d18a91361bbdcccbf592315927d56cf13d8b7343 drunk_visvesvaraya 0.00% 0B / 0B 65 5a8b07ec4cc52823f3cbfdb964018623c1ba307bce2c057ccdbde5f4f6990833 big_heisenberg 0.00% 0B / 0B 66 ``` 67 68 `drunk_visvesvaraya` and `big_heisenberg` are stopped containers in the above example. 69 70 Running `docker stats` on all running containers against a Windows daemon. 71 72 ```powershell 73 PS E:\> docker stats 74 CONTAINER CPU % PRIV WORKING SET NET I/O BLOCK I/O 75 09d3bb5b1604 6.61% 38.21 MiB 17.1 kB / 7.73 kB 10.7 MB / 3.57 MB 76 9db7aa4d986d 9.19% 38.26 MiB 15.2 kB / 7.65 kB 10.6 MB / 3.3 MB 77 3f214c61ad1d 0.00% 28.64 MiB 64 kB / 6.84 kB 4.42 MB / 6.93 MB 78 ``` 79 80 Running `docker stats` on multiple containers by name and id against a Windows daemon. 81 82 ```powershell 83 PS E:\> docker ps -a 84 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 85 3f214c61ad1d nanoserver "cmd" 2 minutes ago Up 2 minutes big_minsky 86 9db7aa4d986d windowsservercore "cmd" 2 minutes ago Up 2 minutes mad_wilson 87 09d3bb5b1604 windowsservercore "cmd" 2 minutes ago Up 2 minutes affectionate_easley 88 89 PS E:\> docker stats 3f214c61ad1d mad_wilson 90 CONTAINER CPU % PRIV WORKING SET NET I/O BLOCK I/O 91 3f214c61ad1d 0.00% 46.25 MiB 76.3 kB / 7.92 kB 10.3 MB / 14.7 MB 92 mad_wilson 9.59% 40.09 MiB 27.6 kB / 8.81 kB 17 MB / 20.1 MB 93 ``` 94 95 ### Formatting 96 97 The formatting option (`--format`) pretty prints container output 98 using a Go template. 99 100 Valid placeholders for the Go template are listed below: 101 102 Placeholder | Description 103 ------------ | -------------------------------------------- 104 `.Container` | Container name or ID (user input) 105 `.Name` | Container name 106 `.ID` | Container ID 107 `.CPUPerc` | CPU percentage 108 `.MemUsage` | Memory usage 109 `.NetIO` | Network IO 110 `.BlockIO` | Block IO 111 `.MemPerc` | Memory percentage (Not available on Windows) 112 `.PIDs` | Number of PIDs (Not available on Windows) 113 114 115 When using the `--format` option, the `stats` command either 116 outputs the data exactly as the template declares or, when using the 117 `table` directive, includes column headers as well. 118 119 The following example uses a template without headers and outputs the 120 `Container` and `CPUPerc` entries separated by a colon for all images: 121 122 ```bash 123 {% raw %} 124 $ docker stats --format "{{.Container}}: {{.CPUPerc}}" 125 126 09d3bb5b1604: 6.61% 127 9db7aa4d986d: 9.19% 128 3f214c61ad1d: 0.00% 129 {% endraw %} 130 ``` 131 132 To list all containers statistics with their name, CPU percentage and memory 133 usage in a table format you can use: 134 135 ```bash 136 {% raw %} 137 $ docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" 138 139 CONTAINER CPU % PRIV WORKING SET 140 1285939c1fd3 0.07% 796 KiB / 64 MiB 141 9c76f7834ae2 0.07% 2.746 MiB / 64 MiB 142 d1ea048f04e4 0.03% 4.583 MiB / 64 MiB 143 {% endraw %} 144 ```