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

24 lines
881 B
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 exec 命令</h1>
<p><strong>docker exec </strong>在运行的容器中执行命令</p>
<h3>语法</h3>
<pre><code class="language-Docker">docker exec [OPTIONS] CONTAINER COMMAND [ARG...]</code></pre>
<p>OPTIONS说明</p>
<ul><li>
<p><strong>-d :</strong>分离模式: 在后台运行</p></li><li>
<p><strong>-i :</strong>即使没有附加也保持STDIN 打开</p></li><li>
<p><strong>-t :</strong>分配一个伪终端</p>
</li></ul>
<h3>实例</h3>
<p>在容器mynginx中以交互模式执行容器内/root/runoob.sh脚本</p><p>
</p><pre><code class="language-Docker">runoob@runoob:~$ docker exec -it mynginx /bin/sh /root/runoob.sh
http://www.runoob.com/
</code></pre>
<p>在容器mynginx中开启一个交互模式的终端</p>
<pre><code class="language-Docker">runoob@runoob:~$ docker exec -i -t mynginx /bin/bash
</code></pre>