How to use gpiozero inside a docker container on a Pi5? #1117
Replies: 2 comments 8 replies
-
To access the 40-pin GPIO headers on the Pi 5 you only need /dev/gpiomem4. The Dockerfile: FROM ubuntu:23.04
RUN apt update && apt install -y python3-pip python3-lgpio python3-pigpio python3-rpi.gpio
RUN pip3 install gpiozero --break-system-packages
CMD ["python3"] Then build and run. This will drop you into the Python REPL: docker build -t gpiozerotest . && docker run -it --privileged --device /dev/gpiomem4:/dev/gpiomem4 gpiozerotest Now import gpiozero and turn a LED on/off from gpiozero import LED
led = LED(17)
while True:
led.on()
led.off() On the oscilloscope I see a signal with a frequency of about 83kHz |
Beta Was this translation helpful? Give feedback.
-
I gues I was about unclear about the link. The link isn't for the workaround, but for the issue. The problem described in #891 (comment) would arise when using gpiozero < 2.0. Libgpiod has some tools to get information about the GPIOs. It should be already installed when using the Raspberry OS.
Run
It doesn't need all three of python3-lgpio python3-pigpio python3-rpi.gpio. Using just python3-lgpio works and seems to be switching about 10k faster. I have no clue why that is. |
Beta Was this translation helpful? Give feedback.
-
Can anyone help with using gpiozero in a docker container on a Pi5?
On a Pi4 it works by adding
--device=/dev/gpiomem:/dev/gpiomem
on thedocker run
command, but on the Pi5 there isn't a /dev/gpiomem instead there are multiple:I've tried using all those but nothing -
sudo docker run --rm --privileged --device /dev/gpiomem0:/dev/gpiomem0 --device /dev/gpiomem1:/dev/gpiomem1 --device /dev/gpiomem2:/dev/gpiomem2 --device /dev/gpiomem3:/dev/gpiomem3 --device /dev/gpiomem4:/dev/gpiomem4 --device /dev/gpiochip0:/dev/gpiochip0 --device /dev/gpiochip1:/dev/gpiochip1 --device /dev/gpiochip2:/dev/gpiochip2 --device /dev/gpiochip3:/dev/gpiochip3 --device /dev/gpiochip4:/dev/gpiochip4 docker.io/antelder/rpiblink-ubuntu
the docker runs but doesn't control the actual gpio pins.Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions