Install Node-RED Inside Docker Container on Linux

Install Node-RED Inside Docker Container on Linux

Node-RED is a flow-based development tool designed for visual programming for wiring together hardware devices, APIs, and online services as part of the Internet of Things (IoT). It provides a browser-based editor that makes it easy to wire together flows using a wide range of nodes in the palette.

This tutorial explains how to install Node-RED inside a Docker container on Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install Node-RED

Before starting, create directory for data:

sudo mkdir -p /opt/node-red/data

Set user, which ID is 1000 as owner for newly created directory:

sudo chown -R 1000:1000 /opt/node-red

Note: it doesn't matter that user (ID: 1000) doesn't exist on host system. This user will be created in the container.

  • Host network

Run the following command to create a container for Node-RED that uses host network:

docker run -d --name=node-red --restart=always --network=host \
    -v /opt/node-red/data:/data \
    nodered/node-red
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, Node-RED service is listening on port 1880. It can be changed with -p option.

docker network create app-net
docker run -d --name=node-red --restart=always --network=app-net \
    -p 8080:1880 \
    -v /opt/node-red/data:/data \
    nodered/node-red

Testing Node-RED

To access a web UI, go to http://<IP_ADDRESS>:1880, where <IP_ADDRESS> is the IP address of the system.

Node-RED Inside Docker Container on Linux

Uninstall Node-RED

To completely remove Node-RED, remove its container:

docker rm --force node-red

Remove Node-RED image:

docker rmi nodered/node-red

You can also remove Node-RED data:

sudo rm -rf /opt/node-red

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.