Node-Red Installation With DOCKER

Pranav Thakkar
4 min readFeb 22, 2021

--

Hi there!! So you are here to get the idea of installing Node-red with Docker.

If you don’t know what is Node-red and docker. Let me explain its applications. after you can find much documentation of it.

So, Node-red is a flow-based visual programing language for many applications like IoT(mostly), for Backend service for IT and when IoT comes there are lots of applications(Retail IoT, Machine IoT, ah! Home Automation, Agricultural IoT) where we can use it. So I’m not going to the specific details on this.

and Docker: It is like your VM. where it is running on your host os and have an IMAGE of your application where you run your application. so you don’t have a dependency on your os or any version of the os. All the images are running under the Container and this image is available at HOST DOCKER HUB. where you can find your one. if not you can even create your own also and publish it there.

So what’s the use of both of these. Let me straight forward. when you want to develop an app with Node-red and wanted it to scale it in a large deployment. You can either clone the copy of that program file(raspberry pi) or you can make the image out of it. and put it to the DOCKER HUB. so only you have to download the image.

For installing Node-red in ubuntu use this link.

Let me help you first of all with the official installation with the docker on ubuntu.

$  sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
and make the docker.sock executable$ sudo usermod -aG docker (user)or if any error use this
sudo chmod 666 /var/run/docker.sock

so after installing the Docker. now we move forward to making a container of Node-red. if you don’t know what is container and docker-engine let me show you a pic this can be a thousand words for you.

here the docker host has our containers. the registry has official images which can be download or uploaded. and docker client is for making run the container or manipulating the container. knowMore

So let’s get back to our installation

make a directory where your Node-red files can be stored on your host OS(Ubuntu). and it will be used fully in your Node-red container.

sudo mkdir node_red_data

#then use this command for installation
docker run -it -p 1880:1880 -v node_red_data:/data --name dockerNR nodered/node-red

so your Node-red image will first be downloaded and then it makes a container out of it named dockerNR. then there are a bunch of commands which you may not need but for learning to manipulate the container.

#list of containers
docker container ls or docker ps -a

#list of an images
docker image ls

#list of volumes
docker volume ls

#list of networks for connecting the container together or with the host.
docker network ls

#for your docker information
docker info

for Start-stop that type of thing

docker start <container name>or <container id>

docker stop <container name>or <container id>

for removing the docker containers

docker rm <container name> or for all container remove docker rm -fv $(docker ps -aq)

and lastly, if you want to inspect the container use this.

docker inspect <container id>or <container name>

but this all command have to remember to perform. instead of this, we can use portainer which is GUI-based for docker communication.

for installation

docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

and after all that above thing if you are restarting the ubuntu you need to add this line so it will automatically start docker containers after every boot.

docker update --restart unless-stopped $(docker ps -q)

So ya! Portainer is user-friendly. no need to introduce more about it.

Portainer.io

so now you can do multiple things like making a new network and connect it to the MQTT container. and grafana(dashboard)and other containers to make all connected internally. also after that, you can push this Node-red image to the docker hub which can be possible via CLI.

and then you can make crontab for getting the latest image of your docker hub for installation.

Thanks and do reply if you found any error or any question.

--

--

Pranav Thakkar

IIoT4.0, Data Analytics Love to collaborate with open source projects