Skip to content

Instantly share code, notes, and snippets.

@scottsbaldwin
Created September 29, 2016 20:51
Show Gist options
  • Save scottsbaldwin/607fa2cf565cefede6b66e69296f34bf to your computer and use it in GitHub Desktop.
Save scottsbaldwin/607fa2cf565cefede6b66e69296f34bf to your computer and use it in GitHub Desktop.
Execute a function on docker stop
#!/bin/sh
handler() {
echo "Caught SIGTERM signal"
exit $((15+128))
}
i=0;
trap 'handler' SIGTERM
while [ $i -lt 600 ]; do
echo Hello world!;
((i=i+1));
sleep 1;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment