This repository was archived by the owner on Jul 28, 2024. It is now read-only.

Description
Node.JS Foundation publishes a Docker Best Practices Guide. The guide references some recommended best practices that may not be implemented in GoogleCloudPlatform/nodejs-docker.
Question: Has Google handled the issues in the guide in some other way or is the best practice for a company to create their own node Docker image that implements these recommendations?
-
INIT
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 SIGTERM (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
In the three areas docker run is referenced in this repo, --init node is not used
-
SIGTERM and SIGINT
When creating an image, you can bypass the package.json's start command and bake it directly into the image itself. First off this reduces the number of processes running inside of your container. Secondly it causes exit signals such as SIGTERM and SIGINT to be received by the Node.js process instead of npm swallowing them.