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