I have trouble to get Modbus working inside a Docker container.
I am using RPI OS 64-bit latest version. Image nodered/node-red:latest
Node.js v16.16.0
Linux 5.15.76-v8+ arm64 LE
I have the same problem.
With the command
"docker run -it -p 1880:1880 -v node_red_data:/data --name node-red --device=/dev/ttyUSB1 nodered/node-red"
docker starts.
With the command
"docker run -it -p 1880:1880 -v node_red_data:/data --name node-red --group-add dialout --device=/dev/ttyUSB1 nodered/node-red" or "docker run -it -u node-red:dialout -p 1880:1880 -v node_red_data:/data --name node-red --device=/dev/ttyUSB1 nodered/node-red"
i get a segfault:
30 Jan 09:51:59 - [info] Started flows
./entrypoint.sh: line 14: 7 Segmentation fault (core dumped) /usr/local/bin/node $NODEOPTIONS node_modules/node-red/red.js --userDir /data $FLOWS
I have installed debian + node-red on the same docker host. in this constellation everything works.
Nice to hear from you. In the mean time I solved the problem. However I am using docker-compose to install node-red but this is not essential.
Maybe start as follows: $ docker exec -it node-red bash
Check your ports using: # ls -l /dev/serial/by-id
Is your port there?
If yes, continue with: # whoami
If your port is not there: it worked out well using ‘root’ as node-red user. The --group-add dialout did not make the difference. An other thing I had to do to make it work is the following. From the palette I installed node-red-node-serialport (although I did not need it), then go back in the docker container with:
$ docker exec -it node-red bash
And, as your data directory is /data do as follows at the bash prompt:
# cd /data/node_modules/node-red-node-serialport
# npm rebuild --build-from-source
# cd ../serialport
# npm rebuild --build-from-source
# cd ../node-red-contrib-modbus
# npm rebuild --build-from-source
This with user=root did the job.
I am using docker-compose to install node-red and I set the user to root. I am passing the parameters I need in node-red through environment variables, all collected in one file. Here you find a few of them under environment.
thanks for your quick reply.
I will try the days and hopefully report with success.
In the meantime i have created a Bug report. Let's see if one of the developers can help.