dumb-init with docker + npm run start
Closed this issue · 1 comments
Dumb-init does not seem to work for me when it is used as the main process in a docker container and when the underlying command uses npm.
Run a docker container with entrypoint ["dumb-init", "--"]
and command ["npm", "run", "start"]
, where the start
script is defined in a package.json to be "node index.js". Add this to "index.js":
'use strict';
const internals = {};
process.on('SIGTERM', function() {
console.log('received signal SIGTERM');
internals.exit();
});
const inverval = setInterval(() => {
console.log('abc');
}, 1 * 1000);
internals.exit = function() {
clearInterval(inverval);
};
Now if I send SIGTERM to PID 1 (the dumb-init process), the process just exits without ever printing received signal SIGTERM
. However, when I exec into a running docker container and run this procedure in a separate process, where dumb-init -- ... does not have PID 1, then the signal is printed correctly before exiting.
Thanks for the issue! I'm having some trouble reproducing it, though.
Here's the code I'm using: https://gist.github.com/anonymous/a6c86cf0b38eeefbcaf246d113db055c
I'm using these steps:
git clone https://gist.github.com/anonymous/a6c86cf0b38eeefbcaf246d113db055c
cd a6c86cf0b38eeefbcaf246d113db055c
docker build -t ckuehl-test .
docker run ckuehl-test
- In another terminal, running
docker ps | grep ckuehl-test
, noting the container ID, then runningdocker kill --signal=TERM <id>
.
In the original terminal I see:
> test@ start /
> nodejs test.js
abc
abc
abc
abc
received signal SIGTERM
...and then it exits.
Can you let me know if i'm doing anything different than you are when trying to reproduce it?