atupal atupal - 3 years ago 182
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?

Answer Source

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 :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download