docker-node
docker-node copied to clipboard
pressing ctrl-c does not result in aborting node
Environment
- Platform: Debian 10
- Docker Version: 20.10.17
- Node.js Version: 20.3.1
- Image Tag: node:20.3-Alpine3.18
Expected Behavior
Pressing ctrl-c when running a simple nodejs script should emit a sigint and stop node.
Current Behavior
Pressing ctrl-c is ignored
Steps to Reproduce
Create in a empty dir the following files:
Dockerfile:
FROM node:20.3-alpine3.18
COPY . .
RUN npm install
CMD [ "npm", "start" ]
package.json
{
"name": "test",
"version": "1.0.0",
"main": "test.js",
"scripts": {
"start": "node test.js"
}
}
test.js
'use strict';
console.log("test");
for (let i=0; i<10; i++) {
task(i);
}
function task(i) {
setTimeout(function() {
console.log(i);
}, 2000 * i);
}
build a docker image with docker build -t test .
run the image with docker run test
press ctrl-c to abort, nothing happens
Additional Information
Works on node:20.2-Alpine3.18
See https://github.com/nodejs/docker-node/blob/7f99010af378daa2520bb60435d0e91e20950d82/docs/BestPractices.md#handling-kernel-signals :eyes: