This gist demonstrates how to access the Raspberry Pi 5 GPIO pins inside a docker container without the need to run Docker with --privileged
Copy Dockerfile and gpiod-test.py onto your host, then run
docker build -t gpiotest . && docker run -it --device /dev/gpiochip4:/dev/gpiochip4 gpiotest
Traceback (most recent call last):
File "//gpiod-test.py", line 6, in
chip = gpiod.Chip('gpiochip4')
File "/usr/lib/python3/dist-packages/gpiod/chip.py", line 58, in init
self._chip = _ext.Chip(path)
~~~~~~~~~^^^^^^
FileNotFoundError: [Errno 2] No such file or directory