Node Docker and SIGTERM

Published on:

I am not sure why but outside of docker your node app will exit immediately
on SIGTERM even if you don't have a SIGTERM handler. But when you run your
app in a docker it does not immediately quit on SIGTERM. It takes 10
seconds and then docker has to SIGKILL it.

This simple app without the SIGTERM handler will need to be killed by Docker. But outside of Docker it exits immediately.

Full example project here:

#!/usr/bin/env node

var log = new(require('loglove'))().log(__filename.substring(process.cwd().length));'we are logging out something here.');

process.on('SIGTERM', function() {

setInterval(function() {'we are logging out something here.');
}, 5000);