i have an entry point script in a docker container that looks something like the following:
#!/bin/bash
echo starting up
function shut_down() {
echo shutting down
pid=$(ps -e | grep myapp | awk '{print $1}')
kill -SIGTERM $pid
exit
}
trap "shut_down" SIGKILL SIGTERM SIGHUP SIGINT EXIT
/opt/myapp
I can't figure out how to trap the signal sent in by running docker stop on the container. When running interactively, a ctrl+c will trigger it as expected, but a docker stop command just waits for the 10 second timeout, and exits without ever entering the shut_down function
How can I trap the signal sent by docker stop in bash to do some cleanup?