Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node 0.11.16 ignores SIGTERM when run inside Docker #5

Closed
skozin opened this issue Feb 3, 2015 · 1 comment
Closed

Node 0.11.16 ignores SIGTERM when run inside Docker #5

skozin opened this issue Feb 3, 2015 · 1 comment

Comments

@skozin
Copy link

skozin commented Feb 3, 2015

Dockerfile:

FROM node:0.11.16
WORKDIR /app
COPY index.js /app/
CMD ["node", "index.js"]

index.js:

console.log('started');
process.stdin.resume();

This app will ignore TERM and INT signals, so it cannot be terminated using Ctrl+C or docker stop.

Other configurations that I have tested:

  • Node.js v0.11.16 in Docker, built from source (Alpine Linux, musl-libc): doesn't exit;
  • Node.js v0.11.16 in Mac OS X, outside of Docker: correctly exits;
  • Node.js v0.10.36, both in Docker and on Mac OS X: correctly exits.

It appears that Node actually recieves and handles these signals, but for some reason doesn't perform the default action. This can be verified by adding signal listeners in index.js:

console.log('started');

exitOnSignal('SIGINT');
exitOnSignal('SIGTERM');
process.stdin.resume();

function exitOnSignal(signal) {
  process.on(signal, function() {
    console.log('\ncaught ' + signal + ', exiting');
    process.exit(1);
  });
}

It correctly prints Caught SIG{INT,TERM} and exits.

@skozin
Copy link
Author

skozin commented Feb 3, 2015

This is most likely an issue in Node.js itself and not in this image. I will open an issue in Node.js repo and close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant