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

Docker Best Practices Node.JS #180

@askhogan

Description

@askhogan

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?

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

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

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