summaryrefslogtreecommitdiff
path: root/devdocs/docker/engine%2Freference%2Fcommandline%2Fstats%2Findex.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/docker/engine%2Freference%2Fcommandline%2Fstats%2Findex.html
new repository
Diffstat (limited to 'devdocs/docker/engine%2Freference%2Fcommandline%2Fstats%2Findex.html')
-rw-r--r--devdocs/docker/engine%2Freference%2Fcommandline%2Fstats%2Findex.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/devdocs/docker/engine%2Freference%2Fcommandline%2Fstats%2Findex.html b/devdocs/docker/engine%2Freference%2Fcommandline%2Fstats%2Findex.html
new file mode 100644
index 00000000..16b8cd99
--- /dev/null
+++ b/devdocs/docker/engine%2Freference%2Fcommandline%2Fstats%2Findex.html
@@ -0,0 +1,62 @@
+<h1>docker stats</h1> <p><br></p> <p>Display a live stream of container(s) resource usage statistics</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker stats [OPTIONS] [CONTAINER...]
+</pre></div> <p>Refer to the <a href="#options">options section</a> for an overview of available <a href="#options"><code class="language-plaintext highlighter-rouge">OPTIONS</code></a> for this command.</p> <h2 id="description">Description</h2> <p name="extended-description">The <code class="language-plaintext highlighter-rouge">docker stats</code> 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.</p> <p>If you need more detailed information about a container’s resource usage, use the <code class="language-plaintext highlighter-rouge">/containers/(id)/stats</code> API endpoint.</p> <blockquote> <p><strong>Note</strong></p> <p>On Linux, the Docker CLI reports memory usage by subtracting cache usage from the total memory usage. The API does not perform such a calculation but rather provides the total memory usage and the amount from the cache so that clients can use the data as needed. The cache usage is defined as the value of <code class="language-plaintext highlighter-rouge">total_inactive_file</code> field in the <code class="language-plaintext highlighter-rouge">memory.stat</code> file on cgroup v1 hosts.</p> <p>On Docker 19.03 and older, the cache usage was defined as the value of <code class="language-plaintext highlighter-rouge">cache</code> field. On cgroup v2 hosts, the cache usage is defined as the value of <code class="language-plaintext highlighter-rouge">inactive_file</code> field.</p> </blockquote> <blockquote> <p><strong>Note</strong></p> <p>The <code class="language-plaintext highlighter-rouge">PIDS</code> column contains the number of processes and kernel threads created by that container. Threads is the term used by Linux kernel. Other equivalent terms are “lightweight process” or “kernel task”, etc. A large number in the <code class="language-plaintext highlighter-rouge">PIDS</code> column combined with a small number of processes (as reported by <code class="language-plaintext highlighter-rouge">ps</code> or <code class="language-plaintext highlighter-rouge">top</code>) may indicate that something in the container is creating many threads.</p> </blockquote> <p>For example uses of this command, refer to the <a href="#examples">examples section</a> below.</p> <h2 id="options">Options</h2> <table> <thead> <tr> <td>Name, shorthand</td> <td>Default</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>
+<code class="language-plaintext highlighter-rouge">--all</code> , <code class="language-plaintext highlighter-rouge">-a</code>
+</td> <td></td> <td>Show all containers (default shows just running)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--format</code></td> <td></td> <td>Pretty-print images using a Go template</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--no-stream</code></td> <td></td> <td>Disable streaming stats and only pull the first result</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--no-trunc</code></td> <td></td> <td>Do not truncate output</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <p>Running <code class="language-plaintext highlighter-rouge">docker stats</code> on all running containers against a Linux daemon.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker stats
+
+CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
+b95a83497c91 awesome_brattain 0.28% 5.629MiB / 1.952GiB 0.28% 916B / 0B 147kB / 0B 9
+67b2525d8ad1 foobar 0.00% 1.727MiB / 1.952GiB 0.09% 2.48kB / 0B 4.11MB / 0B 2
+e5c383697914 test-1951.1.kay7x1lh1twk9c0oig50sd5tr 0.00% 196KiB / 1.952GiB 0.01% 71.2kB / 0B 770kB / 0B 1
+4bda148efbc0 random.1.vnc8on831idyr42slu578u3cr 0.00% 1.672MiB / 1.952GiB 0.08% 110kB / 0B 578kB / 0B 2
+</pre></div> <p>If you don’t <a href="#formatting">specify a format string using <code class="language-plaintext highlighter-rouge">--format</code></a>, the following columns are shown.</p> <table> <thead> <tr> <th>Column name</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>
+<code class="language-plaintext highlighter-rouge">CONTAINER ID</code> and <code class="language-plaintext highlighter-rouge">Name</code>
+</td> <td>the ID and name of the container</td> </tr> <tr> <td>
+<code class="language-plaintext highlighter-rouge">CPU %</code> and <code class="language-plaintext highlighter-rouge">MEM %</code>
+</td> <td>the percentage of the host’s CPU and memory the container is using</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">MEM USAGE / LIMIT</code></td> <td>the total memory the container is using, and the total amount of memory it is allowed to use</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">NET I/O</code></td> <td>The amount of data the container has sent and received over its network interface</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">BLOCK I/O</code></td> <td>The amount of data the container has read to and written from block devices on the host</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">PIDs</code></td> <td>the number of processes or threads the container has created</td> </tr> </tbody> </table> <p>Running <code class="language-plaintext highlighter-rouge">docker stats</code> on multiple containers by name and id against a Linux daemon.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker stats awesome_brattain 67b2525d8ad1
+
+CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
+b95a83497c91 awesome_brattain 0.28% 5.629MiB / 1.952GiB 0.28% 916B / 0B 147kB / 0B 9
+67b2525d8ad1 foobar 0.00% 1.727MiB / 1.952GiB 0.09% 2.48kB / 0B 4.11MB / 0B 2
+</pre></div> <p>Running <code class="language-plaintext highlighter-rouge">docker stats</code> on container with name nginx and getting output in <code class="language-plaintext highlighter-rouge">json</code> format.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker stats nginx --no-stream --format "{{ json . }}"
+{"BlockIO":"0B / 13.3kB","CPUPerc":"0.03%","Container":"nginx","ID":"ed37317fbf42","MemPerc":"0.24%","MemUsage":"2.352MiB / 982.5MiB","Name":"nginx","NetIO":"539kB / 606kB","PIDs":"2"}
+</pre></div> <p>Running <code class="language-plaintext highlighter-rouge">docker stats</code> with customized format on all (Running and Stopped) containers.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker stats --all --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" fervent_panini 5acfcb1b4fd1 drunk_visvesvaraya big_heisenberg
+
+CONTAINER CPU % MEM USAGE / LIMIT
+fervent_panini 0.00% 56KiB / 15.57GiB
+5acfcb1b4fd1 0.07% 32.86MiB / 15.57GiB
+drunk_visvesvaraya 0.00% 0B / 0B
+big_heisenberg 0.00% 0B / 0B
+</pre></div> <p><code class="language-plaintext highlighter-rouge">drunk_visvesvaraya</code> and <code class="language-plaintext highlighter-rouge">big_heisenberg</code> are stopped containers in the above example.</p> <p>Running <code class="language-plaintext highlighter-rouge">docker stats</code> on all running containers against a Windows daemon.</p> <div class="highlight"><pre class="highlight" data-language="">PS E:\&gt; docker stats
+CONTAINER ID CPU % PRIV WORKING SET NET I/O BLOCK I/O
+09d3bb5b1604 6.61% 38.21 MiB 17.1 kB / 7.73 kB 10.7 MB / 3.57 MB
+9db7aa4d986d 9.19% 38.26 MiB 15.2 kB / 7.65 kB 10.6 MB / 3.3 MB
+3f214c61ad1d 0.00% 28.64 MiB 64 kB / 6.84 kB 4.42 MB / 6.93 MB
+</pre></div> <p>Running <code class="language-plaintext highlighter-rouge">docker stats</code> on multiple containers by name and id against a Windows daemon.</p> <div class="highlight"><pre class="highlight" data-language="">PS E:\&gt; docker ps -a
+CONTAINER ID NAME IMAGE COMMAND CREATED STATUS PORTS NAMES
+3f214c61ad1d awesome_brattain nanoserver "cmd" 2 minutes ago Up 2 minutes big_minsky
+9db7aa4d986d mad_wilson windowsservercore "cmd" 2 minutes ago Up 2 minutes mad_wilson
+09d3bb5b1604 fervent_panini windowsservercore "cmd" 2 minutes ago Up 2 minutes affectionate_easley
+
+PS E:\&gt; docker stats 3f214c61ad1d mad_wilson
+CONTAINER ID NAME CPU % PRIV WORKING SET NET I/O BLOCK I/O
+3f214c61ad1d awesome_brattain 0.00% 46.25 MiB 76.3 kB / 7.92 kB 10.3 MB / 14.7 MB
+9db7aa4d986d mad_wilson 9.59% 40.09 MiB 27.6 kB / 8.81 kB 17 MB / 20.1 MB
+</pre></div> <h3 id="formatting">Formatting</h3> <p>The formatting option (<code class="language-plaintext highlighter-rouge">--format</code>) pretty prints container output using a Go template.</p> <p>Valid placeholders for the Go template are listed below:</p> <table> <thead> <tr> <th>Placeholder</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code class="language-plaintext highlighter-rouge">.Container</code></td> <td>Container name or ID (user input)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Name</code></td> <td>Container name</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.ID</code></td> <td>Container ID</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.CPUPerc</code></td> <td>CPU percentage</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.MemUsage</code></td> <td>Memory usage</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.NetIO</code></td> <td>Network IO</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.BlockIO</code></td> <td>Block IO</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.MemPerc</code></td> <td>Memory percentage (Not available on Windows)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.PIDs</code></td> <td>Number of PIDs (Not available on Windows)</td> </tr> </tbody> </table> <p>When using the <code class="language-plaintext highlighter-rouge">--format</code> option, the <code class="language-plaintext highlighter-rouge">stats</code> command either outputs the data exactly as the template declares or, when using the <code class="language-plaintext highlighter-rouge">table</code> directive, includes column headers as well.</p> <p>The following example uses a template without headers and outputs the <code class="language-plaintext highlighter-rouge">Container</code> and <code class="language-plaintext highlighter-rouge">CPUPerc</code> entries separated by a colon (<code class="language-plaintext highlighter-rouge">:</code>) for all images:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker stats --format "{{.Container}}: {{.CPUPerc}}"
+
+09d3bb5b1604: 6.61%
+9db7aa4d986d: 9.19%
+3f214c61ad1d: 0.00%
+</pre></div> <p>To list all containers statistics with their name, CPU percentage and memory usage in a table format you can use:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"
+
+CONTAINER CPU % PRIV WORKING SET
+1285939c1fd3 0.07% 796 KiB / 64 MiB
+9c76f7834ae2 0.07% 2.746 MiB / 64 MiB
+d1ea048f04e4 0.03% 4.583 MiB / 64 MiB
+</pre></div> <p>The default format is as follows:</p> <p>On Linux:</p> <div class="highlight"><pre class="highlight" data-language="">"table {{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.PIDs}}"
+</pre></div> <p>On Windows:</p> <div class="highlight"><pre class="highlight" data-language="">"table {{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}"
+</pre></div> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
+ <a href="https://docs.docker.com/engine/reference/commandline/stats/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/stats/</a>
+ </p>
+</div>