linuxsignalsdocker

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?


Solution

  • 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 : http://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/