• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error when using GPIO from Python

I have a docker that runs a Python application which uses GPIOs (via the Python RPi.GPIO library).

This docker runs fine on the Raspberry Pi 3B, but not on the netPI. I get:
RuntimeError: No access to /dev/mem.  Try running as root!

Further information:
- I do start the docker container with the `--priviliged` option.
- I have not yet attached a DI DO extension the netPI. I assume the module is "just" extending the GPIOs to the outside.
- On the Raspberry Pi, I don't use portainer.
- I've upgraded the firmware of the netPI to the latest version on September 5.

Are there any differences between the netPI and Raspberry Pi concerning the GPIOs or am I doing something wrong?

This is very easy to explain: netPI has a special Docker daemon software that does not map all "/dev/" devices automatically into a container even if you configured it to "--privileged" mode. This is because of security reasons. You have to add all devices manually in any case.

With netPI you have to map the device /dev/mem into the container when you start it. That's all.

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

Thanks, Armin.

I tried that, but it gives another error: "Linux runtime spec devices: not allowing /dev/mem for security reasons".

I guess i am missing something or the linux in my container is also "too" secure.

Any ideas?

Yes please follow the idea of the example container https://hub.docker.com/r/hilschernetpi/netpi-nodered.

For this container we mapped /dev/gpiomem.

This should work.
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

It does. Thanks!

Possibly Related Threads…
Thread Author Replies Views Last Post
  cannot execute file: Exec format error - NETPI tuliosouza 1 128 January-13th-2022, 01:17 PM
Last Post: Armin@netPI
  netPI opc ua server pull image error wswitula 3 1,008 August-27th-2021, 10:47 AM
Last Post: wswitula
  HilscherAutomation / netPI-bluetooth entrypoint.sh error bbaskii 6 1,933 September-14th-2020, 04:42 PM
Last Post: bbaskii
  Error when using a node 'OpcUaServer' tad 6 2,310 May-12th-2020, 08:35 AM
Last Post: tad
  netPI Node-Red fieldbus node Error PersEE 5 2,816 October-8th-2019, 03:55 PM
Last Post: Armin@netPI
  "node-red with NIOT-E-NPIX-EVA GPIO module" Docker image Eyad.Almolki 1 1,033 July-30th-2018, 06:22 PM
Last Post: Armin@netPI
  Python SteveO 2 1,360 April-11th-2018, 06:46 AM
Last Post: Armin@netPI
  fieldbus in error Schranz 7 2,428 March-13th-2018, 07:28 AM
Last Post: Armin@netPI

Forum Jump:

Users browsing this thread: 1 Guest(s)