如何为 dockerized nodeJS 应用程序设置正确的组成员

How to set correct group member for dockerized nodeJS application

我需要 运行 一个 docker 容器和一个使用 rpio 包的应用程序。

我不明白这部分:

By default the module will use /dev/gpiomem when using simple GPIO access. To access this device, your user will need to be a member of the gpio group, and you may need to configure udev with the following rule (as root):

$ cat >/etc/udev/rules.d/20-gpiomem.rules <<EOF
SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="gpio",
MODE="0660" EOF

For access to i²c, PWM, and SPI, or if you are running an older kernel which does not have the bcm2835-gpiomem module, you will need to run your programs as root for access to /dev/mem.

由于我 运行 在 docker image/container 中安装我的 nodeJS 应用程序,我不明白如何设置组成员以及成员名称和调用位置udev 规则命令。

非常感谢您的每一个解释。

docker 用户(应该是登录用户,例如 "pi")需要在 "gpio" 组中。

# see all groups the user is assigned to
groups

# if the user is not assigned to gpio, run the following:
sudo adduser $(whoami) gpio

您需要使设备 /dev/gpiomem 在 docker 容器内可用。

# e.g.
docker run -d --device /dev/gpiomem <image>