docker-node
docker-node copied to clipboard
Kernel signal handling guide still up-to-date?
I read this in the Docker and Node.js Best Practices:
Handling Kernel Signals
Node.js was not designed to run as PID 1 which leads to unexpected behaviour when running inside of Docker. For example, a Node.js process running as PID 1 will not respond to SIGINT (CTRL-C) and similar signals. As of Docker 1.13, you can use the --init flag to wrap your Node.js process with a lightweight init system that properly handles running as PID 1.
docker run -it --init node
You can also include Tini directly in your Dockerfile, ensuring your process is always started with an init wrapper.
At the same time, I read Top 4 Tactics To Keep Node.js Rockin’ in Docker article on Docker blog where it says this:
TL;DR: Except for local development, don’t wrap your node startup commands with anything. Don’t use npm, nodemon, etc. Have your Dockerfile CMD be something like [“node”, “file-to-start.js”] and you’ll have an easier time managing and replacing your containers.
and this:
I recommend calling the node binary directly, largely due to the “PID 1 Problem” where you’ll find some confusion and misinformation online about how to deal with this in Node.js apps. To clear up confusion in the blogosphere, you don’t always need a “init” tool to sit between Docker and Node.js, and you should probably spend more time thinking about how your app stops gracefully.
I'm confused by these opposing views and not sure who to believe and which recommendation to use moving forward.
Do we still need tini/pm2/nodemon/s6/etc or we can run node command straight, without wrappers?
Thanks in advance!