I have a program run in a docker container with detached mode.
So how to send a signal such as SIGINT to this program?
We know that docker stop sends a SIGTERM to the container process.
Like it was mentioned, if you are already inside of a container, then just use ps -eaf command to see the running processes.
You can use docker kill --signal="<signal>" <container name or id>
to send any signal to the root process of a given container.
See https://docs.docker.com/engine/reference/commandline/kill/#send-a-custom-signal--to-a-container
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With