89luca89 / distrobox

Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
https://distrobox.it/
GNU General Public License v3.0
10.19k stars 419 forks source link

[Error] Can't access Raspberry Pi 4 GPIO's in container without sudo #1297

Open DPaess opened 8 months ago

DPaess commented 8 months ago

I'm trying to deploy a distrobox container in Raspberry Pi 4 with Raspberry Pi OS using a distrobox container with the following command: distrobox-create --root --image docker.io/library/ros:humble-ros-base-jammy --name humbleV1 --home ~/containers/humbleV1. Inside the container I make sure to install (or update) lgpio and gpiozero. I've set up a python script,teste.py, to test it which consists of simple 3 lines from gpiozero import LED \n led = LED(17) \n led.toggle(). When I run this script with sudo teste.py it works but when I don't use sudo it doesn't work, and I can't use sudo because I need to run this script via ROS2. Any ideias? I tried some flags of distrobox (unshare-process,unshare-netns,unshare-devsys) and messing with group access but it didn't work. The error is in the image bellow ( it sometimes runs another one that cant find pin factory but it changes to this after setting pin factory with the command export GPIOZERO_PIN_FACTORY=lgpio) image

89luca89 commented 8 months ago

Hi @DPaess

the user inside the container does not have the same groups as outside so you should add yourself to the same groups also inside, in this case, to access the GPIO

DPaess commented 8 months ago

Hi @DPaess

the user inside the container does not have the same groups as outside so you should add yourself to the same groups also inside, in this case, to access the GPIO

I already tried that, inside the container we have ubuntu which uses dialout group to acess gpio pins but adding the user to this group is not solving the problem as you can see below: image image

89luca89 commented 5 months ago

@DPaess is the problem persisting?

One thing you should check is that the dialout group has the same GID both inside AND outside the container, then it should work