1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<h1>docker kill</h1> <p><br></p> <p>Kill one or more running containers</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker kill [OPTIONS] CONTAINER [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 kill</code> subcommand kills one or more containers. The main process inside the container is sent <code class="language-plaintext highlighter-rouge">SIGKILL</code> signal (default), or the signal that is specified with the <code class="language-plaintext highlighter-rouge">--signal</code> option. You can reference a container by its ID, ID-prefix, or name.</p> <p>The <code class="language-plaintext highlighter-rouge">--signal</code> (or <code class="language-plaintext highlighter-rouge">-s</code> shorthand) flag sets the system call signal that is sent to the container. This signal can be a signal name in the format <code class="language-plaintext highlighter-rouge">SIG<NAME></code>, for instance <code class="language-plaintext highlighter-rouge">SIGINT</code>, or an unsigned number that matches a position in the kernel’s syscall table, for instance <code class="language-plaintext highlighter-rouge">2</code>.</p> <p>While the default (<code class="language-plaintext highlighter-rouge">SIGKILL</code>) signal will terminate the container, the signal set through <code class="language-plaintext highlighter-rouge">--signal</code> may be non-terminal, depending on the container’s main process. For example, the <code class="language-plaintext highlighter-rouge">SIGHUP</code> signal in most cases will be non-terminal, and the container will continue running after receiving the signal.</p> <blockquote> <p><strong>Note</strong></p> <p><code class="language-plaintext highlighter-rouge">ENTRYPOINT</code> and <code class="language-plaintext highlighter-rouge">CMD</code> in the <em>shell</em> form run as a child process of <code class="language-plaintext highlighter-rouge">/bin/sh -c</code>, which does not pass signals. This means that the executable is not the container’s PID 1 and does not receive Unix signals.</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">--signal</code> , <code class="language-plaintext highlighter-rouge">-s</code>
</td> <td><code class="language-plaintext highlighter-rouge">KILL</code></td> <td>Signal to send to the container</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <h3 id="send-a-kill-signal-to-a-container">Send a KILL signal to a container</h3> <p>The following example sends the default <code class="language-plaintext highlighter-rouge">SIGKILL</code> signal to the container named <code class="language-plaintext highlighter-rouge">my_container</code>:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker kill my_container
</pre></div> <h3 id="send-a-custom-signal-to-a-container">Send a custom signal to a container</h3> <p>The following example sends a <code class="language-plaintext highlighter-rouge">SIGHUP</code> signal to the container named <code class="language-plaintext highlighter-rouge">my_container</code>:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker kill --signal=SIGHUP my_container
</pre></div> <p>You can specify a custom signal either by <em>name</em>, or <em>number</em>. The <code class="language-plaintext highlighter-rouge">SIG</code> prefix is optional, so the following examples are equivalent:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker kill --signal=SIGHUP my_container
$ docker kill --signal=HUP my_container
$ docker kill --signal=1 my_container
</pre></div> <p>Refer to the <a href="https://man7.org/linux/man-pages/man7/signal.7.html"><code class="language-plaintext highlighter-rouge">signal(7)</code></a> man-page for a list of standard Linux signals.</p> <div class="_attribution">
<p class="_attribution-p">
© 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/kill/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/kill/</a>
</p>
</div>
|