uTools-Manuals/docs/docker/docker ps.html
2019-05-07 10:37:34 +08:00

69 lines
2.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1>Docker ps 命令</h1>
<p><strong>docker ps : </strong>列出容器</p>
<h3>语法</h3>
<pre><code class="language-Docker">docker ps [OPTIONS]</code></pre>
<p>OPTIONS说明</p>
<ul>
<li><p><strong>-a :</strong>显示所有的容器,包括未运行的。</p></li>
<li><p><strong>-f :</strong>根据条件过滤显示的内容。</p><p></p></li>
<li><p><strong>--format :</strong>指定返回值的模板文件。</p></li>
<li><p><strong>-l :</strong>显示最近创建的容器。</p></li>
<li><p><strong>-n :</strong>列出最近创建的n个容器。</p></li>
<li><p><strong>--no-trunc :</strong>不截断输出。</p></li>
<li><p><strong>-q :</strong>静默模式,只显示容器编号。</p></li>
<li><p><strong>-s :</strong>显示总的文件大小。</p></li>
</ul>
<h3>实例</h3>
<p>列出所有在运行的容器信息。</p>
<pre><code class="language-Docker">runoob@runoob:~$ docker ps
CONTAINER ID IMAGE COMMAND ... PORTS NAMES
09b93464c2f7 nginx:latest "nginx -g 'daemon off" ... 80/tcp, 443/tcp myrunoob
96f7f14e99ab mysql:5.6 "docker-entrypoint.sh" ... 0.0.0.0:3306-&gt;3306/tcp mymysql
</code></pre>
<p>列出最近创建的5个容器信息。</p>
<pre><code class="language-Docker">runoob@runoob:~$ docker ps -n 5
CONTAINER ID IMAGE COMMAND CREATED
09b93464c2f7 nginx:latest "nginx -g 'daemon off" 2 days ago ...
b8573233d675 nginx:latest "/bin/bash" 2 days ago ...
b1a0703e41e7 nginx:latest "nginx -g 'daemon off" 2 days ago ...
f46fb1dec520 5c6e1090e771 "/bin/sh -c 'set -x \t" 2 days ago ...
a63b4a5597de 860c279d2fec "bash" 2 days ago ...
</code></pre>
<p>列出所有创建的容器ID。</p>
<pre><code class="language-Docker">runoob@runoob:~$ docker ps -a -q
09b93464c2f7
b8573233d675
b1a0703e41e7
f46fb1dec520
a63b4a5597de
6a4aa42e947b
de7bb36e7968
43a432b73776
664a8ab1a585
ba52eb632bbd
...
</code></pre>