Access Fin RGB LED from another container

Howdy, I’m trying to control the Fin’s RGB LED with the following commands from within one of my apps containers (not from Host) but am getting a read only file system error. Any ideas? Do I need to enable privileged:true in compose?

echo 50 > /sys/class/leds/pca963x:\blue/brightness
bash: /sys/class/leds/pca963x:blue/brightness: Read-only file system

Hi,

Please set privileged:true in your Docker compose file and let us know how it goes.

agent:
       build: ./agent
       privileged: true
       volumes: 
         - 'resin-data:/data' 
       ports:
         - "80:8080"       # Serve agent on port 80 to public
         - "1883:1883"     # Serve MQTT on port 1883 to public

Unfortunately now getting a slightly different error:

echo 50 > /sys/class/leds/pca963x:blue/brightness
bash: /sys/class/leds/pca963x:blue/brightness: Permission denied

Hi there, have you confirmed that these commands work correctly from the host OS? I’ve just deployed a test device here and am running the same commands as you have shared from within a privileged container and they work as expected.

The reason I ask if they work on the host OS is that if you have a Fin v1.0 instead of a Fin v1.1 then the method of controlling LEDs is different and done via GPIOs 504,505 and 506 instead of via sysfs.

If it’s working on the host OS but not in your container please could you share a minimal reproduction of the problem with a Dockerfile that we can use to try to replicate the issue?

@chrisys Thanks for assisting. Indeed the commands work from hostOS on Fin v1.1.
Dockerfile for offending container is pretty darn simple:

FROM losant/edge-agent:latest-arm
EXPOSE 8080/tcp

@barryjump it looks like the user in that container is not root which will most likely be the cause of the permission issue here and explains the error message.

I changed your Dockerfile to:

FROM losant/edge-agent:latest-arm
EXPOSE 8080/tcp
USER root

Then it works :slight_smile:

That did it! Thank you :+1: :+1: