skip to Main Content

I’m running a Node-RED container on Rpi Zero in order to use the rpi-led-control library (https://www.npmjs.com/package/rpi-led-control) but I am unable to use it because I get this error:

Error: EROFS: read-only file system, open '/sys/class/gpio/export'

I’m currently running the container in this way:

docker run -d -p 1880:1880 --group-add dialout --device=/dev/spidev0.0 --device=/dev/spidev0.1 --device=/dev/serial0 --user=root --restart=always -e NODE_OPTIONS="--max_old_space_size=256" --log-opt max-file=2 --log-opt max-size=2k -e TZ="Europe/Rome" braghettos/node-red:latest

My Dockerfile is the following:

FROM nodered/node-red:latest

USER root

RUN npm install node-red-node-serialport xbee-api node-red-contrib-xbee node-red-node-pi-gpiod node-red-contrib-telegrambot node-red-contrib-python-function node-red-node-twitter node-red-contrib-function-npm node-red-contrib-ibm-watson-iot onoff rpi-led-control node-red-contrib-play-audio

COPY ./config/settings.js /data/

RUN mkdir /cert

COPY ./cert/cert.pem /cert
COPY ./cert/key.pem /cert

RUN apk update && apk add py-pip 
        && pip install requests plotly --upgrade

What I want to do is to interact with the SPI pins of the Rpi Zero GPIO from the Node-RED container.

Thanks in advance,

Diego

2

Answers


  1. You need to mount gpio files/filesystem from the host during docker run like this:

    docker run -d -p 1880:1880 
        -v /sys/devices/platform/soc/20200000.gpio:/sys/devices/platform/soc/20200000.gpio 
        -v /sys/class/gpio:/sys/class/gpio 
    ...
    

    The exact file names varies for each Rpi device types, this if for Rpi Zero.

    Login or Signup to reply.
  2. Use the docker run –privileged flag to give the container nearly all the same access to the host as processes running outside containers on the host:

    docker run --privileged -d -p 1880:1880 --group-add dialout --device=/dev/spidev0.0 --device=/dev/spidev0.1 --device=/dev/serial0 --user=root --restart=always -e NODE_OPTIONS="--max_old_space_size=256" --log-opt max-file=2 --log-opt max-size=2k -e TZ="Europe/Rome" braghettos/node-red:latest
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search