在不杀死Docker容器的情况下杀死正在运行的进程(例如Web服务器) [英] Kill a running process like a webserver inside a Docker container without killing the container

查看:277
本文介绍了在不杀死Docker容器的情况下杀死正在运行的进程(例如Web服务器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想杀死Docker容器内的Django Web服务器等正在运行的进程,而不杀死容器本身,但是由于某些原因,如果我这样做 docker exec -it< container> ps -aux ,然后 docker exec< container>杀死< pid> 会杀死我的docker实例,而我却不想这么做。

i want to kill a running process like a Django webserver inside a Docker container without killing the container itself but for some reason if i do docker exec -it <container> ps -aux and then docker exec <container> kill <pid> it will kill my docker instance and i don't want that.

我该如何解决这个问题?

How can i address this issue?

推荐答案

您可以执行以下操作: docker exec -it< container> bash 一旦进入容器,您就可以 kill< pid> 。这将终止该过程,但保持容器运行除非,这是容器启动的过程。

you can go: docker exec -it <container> bash once inside the container you can then kill <pid>. This will kill the process but keep the container running unless this is the process the container was started with.

这篇关于在不杀死Docker容器的情况下杀死正在运行的进程(例如Web服务器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆