Skip to content

Instantly share code, notes, and snippets.

@frncmx
Last active November 8, 2017 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frncmx/b25f91b4732081a732877afb9baa7bad to your computer and use it in GitHub Desktop.
Save frncmx/b25f91b4732081a732877afb9baa7bad to your computer and use it in GitHub Desktop.
Docker CMD and SIGTERM
  1. docker build .
  2. docker run --rm -it IMAGE-ID
  3. from different terminal try docker stop CONTAINER-ID ... won't stop

examina the output of ps aux, who is PID 1?

FROM ubuntu:precise
COPY sigterm-exp /app/
CMD /app/sigterm-exp
#!/usr/bin/env bash
set -euo pipefail
_term() {
echo "Caught SIGTERM signal!"
exit 0
}
trap _term SIGTERM
echo 'ps aux'
ps aux
echo
while true; do
echo "running..."
sleep 3
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment