Node.js on Docker.
This image is based on the Alpine Linux variant of the official Nodejs image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.
The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements. However, most software doesn't have an issue with this, so this variant is usually a very safe choice. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.
To minimize image size, it's uncommon for additional related tools (such as git
or bash
) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine
image description for examples of how to install packages if you are unfamiliar).
docker pull pagerinc/node
docker run -it --rm pagerinc/node node
Currently, this node image comes in LTS flavor, tailored towards a specific use case.
10.15
,latest
: Node.js v10.15.x
Tests are run as part of the Dockerfile
build. To execute them separately within a container, run:
bats test
NODE_ENV
is already set to production
for you. Any other secrets and runtime configuration need to be passed in to your application as well.
eg:
-e "NPM_CONFIG_LOGLEVEL=warn"
By default, Docker runs container as root which inside of the container can pose as a security issue. You would want to run the container as an unprivileged user wherever possible. This image provides the unprivileged node
user for such purpose.
This image uses dumb-init as its entrypoint, dealing with issues such as PID 1 reaping problems for you, no configuration needed.