Docker – Kill a running process inside a docker

cgroupdockerkillprocess

I've run a find command on a very large folder inside my docker, and now it is stuck for more than an hour.

I've tried to kill -9 the process, and kill the docker container with docker kill <containerid>, but nothing helps it move. I can't run anymore commands inside the docker. The host is very responsive.

The process status is R (running). I can't strace it (strace stucks), and kill -9 don't have any effect on it.

I've tried to look the /proc/PID/status file, it shows :

State:  R (running) 
[...]
voluntary_ctxt_switches:    2387
nonvoluntary_ctxt_switches: 29121

The two last numbers are increasing quite fast.

I don't care very much about that docker container or the result of the find command, but I care about the other containers on the same host.

Is there a way to nuke the process or the container without restarting the host ?

Best Answer

when you build Docker, use this command :

RUN apt-get install lsof

then in py file you can use:

os.system("lsof /dev/nvidia* | awk '{print $2}' | xargs -I {} kill {}")

REMEMBER: this command kill all process on GPU