<p>I tried to kill one python process:</p>

<pre><code># ps aux | grep python
root           1 12.6  2.1 2234740 1332316 ?     Ssl  20:04  19:36 /usr/bin/python3 /batch/run.py
root         490  0.0  0.0  11472  1012 pts/0    S+   22:39   0:00 grep --color=auto python
# sudo kill -9 1
# ps aux | grep python
root           1 12.6  2.1 2234740 1333372 ?     Ssl  20:04  19:38 /usr/bin/python3 /batch/run.py
root         494  0.0  0.0  11472  1088 pts/0    S+   22:39   0:00 grep --color=auto python
</code></pre>

<p>Any idea why? Thanks.
Any other information needed to debug this?</p>

<p><strong>UPDATE</strong></p>

<p>In fact, I would not like to kill the container or pod. I modified the python codes in <code>/usr/local/lib/python3.6/dist-packages/</code> directly. If pod restarted, my changes will be gone.</p>

<p><strong>I need to modify third party codes (not my own codes) in the containers and see the results directly.</strong></p>

<p>Updating my own codes and redeploying the docker image is not my first choice in fact. Otherwise, why I ask questions here.</p>

<p><strong>Also, I am curious why it cannot be killed?</strong></p>

<p>Thanks</p>

<p>As mentioned by @coderanger, container has the concept to be immutable.
What you trying to do isn't a good practice in Kubernetes/container environments.</p>

<p><strong>But...</strong></p>

<p>Sometimes a kind of <em>magic</em> is required keep the airplane in flight...  There are some options that could help you:</p>

<p><strong>1.  Rebuild container image</strong></p>

<p>The best solution in this case is rebuild your container image based in the current running image. You could run this image separately from your main workload to test the changes.
That is the best approach in this case, because you'll persist the changes in the image and the historical for rolling updates.</p>

<p><strong>2. Workaround to kill the pid</strong></p>

<p><em>I've tested in a container running flask with supervisord.</em></p>

<p>You could use the <code>SIGHUP</code> signal to restart the process inside your container:</p>

<blockquote>
  <p><strong>SIGHUP</strong> - The SIGHUP signal disconnects a process from the parent process. This an also be used to restart processes. For example, "killall -SIGHUP compiz" will restart Compiz. This is useful for daemons with memory leaks.
  ...
  <strong>SIGHUP</strong> P1990      Term    Hangup detected on controlling terminal
                                         or death of controlling process</p>
</blockquote>

<p>Inside your container, run:</p>

<p><code>kill -SIGHUP &lt;PID&gt;</code> or <code>kill -1 &lt;PID&gt;</code></p>

<p><strong>Sources:</strong>
- <a href="http://man7.org/linux/man-pages/man7/signal.7.html" rel="nofollow noreferrer">http://man7.org/linux/man-pages/man7/signal.7.html</a>
<a href="https://www.linux.org/threads/kill-signals-and-commands-revised.11625/" rel="nofollow noreferrer">https://www.linux.org/threads/kill-signals-and-commands-revised.11625/</a></p>
