- Sending build context to Docker daemon 148.9 MB Step 1 / 10: FROM node:lts-alpine as build-stage - 1c342643aa5c Step 2 / 10: WORKDIR /app - Running in 85955f5faa4a Removing intermediate container 85955 f5faa4a - 597534e7f448 Step 3 / 10: COPY package.json./ - 21c8acaa8351 Step 4 / 10: RUN npm install - Running in c71034cdb324.
- Based on this, let’s ensure that we use the Long Term Support (LTS) version of Node.js, and the minimal alpine image type to have the smallest size and software footprint on the image: FROM node:lts-alpine. Nonetheless, this base image directive will still pull new builds of that tag.
Another option may be to tag the different LTS versions with their code word. Similar to how the Debian Docker Image gets tagged:wheezy etc. The reason why I think this is a good idea is that people who want to be on an LTS version want to be on a specific LTS version until they are ready to jump to the next.
The project makes available a number of different versions of the Docker container on Docker hub which fall into 2 categories:
- Different underlying NodeJS versions. As new NodeJS LTS versions are released coresponding versions of the container are added.
- Images tagged with the
-minimalsuffix. These containers are designed to contian the absolute libraries required to run Node-RED and it’s core nodes.
-minimal containers do not have the native build tools required to build some nodes components triggered by installing them.
Both of these sets of images are based on the NodeJS Alpine containers. Alpine is a Linux distribution tha aims to provide the smallest possible install footprint, it is used as the base for many language runtime containers (e.g. NodeJS & Python). As part of a number of optomisations to reduce the size it uses the musl libc instead of the usual glibc implementation.
Musl works fine with most applications but on some occations it can cause problems e.g. with some of the SAP nodes and with some low level video codec.
If you want to extend the provided Docker containers then then you will need to use Apline’s package management tool
apk to install additional libraries or applications.
Debian based containers
As well as the Alpine based containers the Node-RED Docker git project also includes a script to build a version of the Node-RED Docker containers based on the Debian Linux Distribution. This is useful as Debian is a more mainstream Linux distribution and many nodes include instructions on how to install prerequistes.
You can build the containers locally by running the following commands:
This will a container called
testing:node-red-build which can be run as follows:
This container can be extended to add the required prerequistes for your projects. For example to add the required libraries for the node-red-contrib-machine-learning node the following Dockerfile will extend the previously built container.
This can be build with
The other option is to edit the
Dockerfile.debian to build in the dependencies up front. You can add the packages to the
apt-get line and then add a
pip to install the native Python modules not directly packaged for Debian.
In this case you would just need to rerun the
Here we are about to show how we can install LTS version of Node.JS which includes NPM in Docker container.
First thing you should have Docker on your system or server. You can see the tutorials to install it on Windows 10/7 and Ubuntu Linux.
Download Node.js on Docker
Just go to Docker interface and type the below Node pull command:
The above command will install the latest version of the Node.js while writing this article it was v 12.7.0.
Run Node.js on Docker
To run Node on docker use the below
However, to install the current LTS version that is v10.16.1, you can use its tag.
- tag- 10.16.1-stretch-slim size- 55 MB
- tag- 10.16.1-stretch size- 348 MB
- tag- lts size- 348 MB
For that the Command will be like this:
So to run the 10.16.1-stretch
The command will be the:
If you think that running docker with such a long tag name is a little bit cumbersome then give name to the image name.
For example, to run a particular version of a node when there are multiple images have been installed; we have to define a tag in a command. Thus if we have the latest version of the node along with some other version such as 10.16.1-stretch, so the command will be like this
docker run -it tag imagename
To make it easy we can simply tag a new image name to our existing image.
Suppose we want to tag a name node10 with node:10.16.1-stretch then the command will be
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
Node Lts Dockery
That’s it, now you can simply run the 10.16.1-stretch of a using a simple command
Nodejs Lts Docker Hub
For more Node.Js official Docker tags you can visit the official website of Docker.