Create node that runs a docker while node-red is also running in docker

Hello,

I’m running Node-RED in Docker (and it will be running in Kubernetes soon). I’d like to add custom nodes that are Docker containers themselves. For example, one node will be a local LLM, and another will have some heavy logic running in another Docker container, and so forth.

Any ideas?

Thanks.

A local LLM within a node-red node ?
I may not understand it correctly - but I would not recommend this: separation of concern.

Run a LLM in a container and expose it via some API.
Call the API from node-red.

2 Likes

yes, you are right.

ok, I've used the wrong example. Imagine some heavy processing script written in python. Any way to wrap it inside a docker container that is then wrapped inside a node-red node so that I can use it in node-red ?.

there is nothing stopping your node-red executing docker commands and spinning up containers.

Another way could be to have multiple node-reds running and offload work to them using simple MQTT comms as a control + command API.

keeping everything in Node-RED will give the visual benefits.


company hat on for a moment - most of what you are asking (like spinning up more nodes, docker/Kubernetes orchestration) has pretty much been solved by FlowFuse (which is open source) - maybe worth checking it out?

1 Like

a 'node' within node-red is a node js library which is wrapped as an npm package, which are javascript files that contain all the complexities and functionality. Docker is used for containers, something completely different.

Imagine some heavy processing script written in python

I would do the 'heavy processing' in javascript, although you could call the python script from javascript.

1 Like

waw nice... I definitely will have a look at FlowFuse thanks

yes, I see it. The problem I'm facing is that there is a team creating docker with scripts (and all the dependencies with it) on them written in different languages (such as Python... but not only). So I can run the script with a single docker command line. Now I'd like to create node-red nodes that simply wrap each of those docker so that I can create flows. I guess that it would be something like calling a docker command from JS.... something like Docker in Docker (as node-red is already running in docker).... So wondering if any body did something similar...

I'll investicate what @Steve-Mcl suggested in Create node that runs a docker while node-red is also running in docker - #4 by Steve-Mcl

You could use this: GitHub - philhawthorne/ha-dockermon: A NodeJS RESTful API which can be used with Home Assistant to report the state of Docker Containers
It talks a lot about Home Assistant. But, in fact, it gives a rest interface to the docker engine, that is not linked at all to HA.
You can either use that as an external container or embed the npm code into your nodered environment.

i think that OP is mixing things that don't mix. A node is a node, a container is a container. There is no node that contains a container.

If you want to control containers from node-red you can use dockerode

1 Like

ok... I'll keep the heavy guns on docker but talking to node-red via messages.