Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Node v0.11.16 doesn't exit on SIGTERM when runs inside Docker #9131

Closed
@skozin

Description

@skozin

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. Tested with Docker 1.4.1, Linux kernel 3.16.7.

Other configurations:

  • 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.

Initially I posted this to docker-node repo, but moved it here as it seems unrelated to the particular Docker image.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions