atupal atupal - 8 months ago 68
Linux Question

How to send signal to program run in a docker container?

I have a program run in a docker container with detached mode.

So how to send a signal such as SIGINT to this program?


You can use nsenter to get into your container space and send your signal.

PID=$(docker inspect --format {{.State.Pid}} <container_name_or_ID>)
nsenter --target $PID --mount --uts --ipc --net --pid kill -SIGINT <PID of your program inside your container>

More info :