Answered by:
Azure IoT edge solution module (Dockerfile)- RPi.GPIO RuntimeError on raspberry pi

Question
-
Hi everyone , I created a solution module (python) using VS code for Blinking Led on raspberry pi . To make use of RPi pins installed RPi.GPIO library and created a docker image . When i run this docker image on raspberry pi its throwing a run-time error which is as follows.
Traceback (most recent call last):
File "main.py", line 8, in <module>
GPIO.setup(18, GPIO.OUT)
RuntimeError: No access to /dev/mem. Try running as root!
main.py program
<style type="text/css">@page { margin: 2cm } p { margin-bottom: 0.25cm; line-height: 115% } a:link { so-language: zxx } </style>
#!/usr/bin/env python import RPi.GPIO as GPIO import time # Configure the PIN # 18 GPIO.setmode(GPIO.BOARD) GPIO.setup(18, GPIO.OUT) GPIO.setwarnings(False) # Blink Interval blink_interval = .5 #Time interval in Seconds # Blinker Loop while True: GPIO.output(18, True) time.sleep(blink_interval) GPIO.output(18, False) time.sleep(blink_interval) # Release Resources GPIO.cleanup()
Dockerfile.arm32v7
FROM resin/raspberrypi3-debian:stretch WORKDIR /app ENV PYTHONUNBUFFERED=1 RUN [ "cross-build-start" ] RUN echo "deb http://deb.debian.org/debian jessie main" >> /etc/apt/sources.list RUN sudo apt-get update && sudo apt-get install -y \ build-essential \ python-dev \ python-pip \ python-setuptools \ swig \ zlib1g-dev COPY requirements.txt ./ RUN sudo pip install --upgrade pip RUN sudo pip install -r requirements.txt RUN sudo apt-get install RPi.GPIO COPY . . CMD ["sudo", "python3","main.py" ] RUN [ "cross-build-end" ]
and attaching error screenshot
Thanks for your time
Friday, January 17, 2020 6:53 AM
Answers
-
Hi,
If you are following a document and not able to complete the tutorial you can add an issue directly to the doc.
Here is also the suggested place to discuss Azure IoT Edge topics if they do not relate with a doc (as I believe is the case).
I have misread your question and thought you were reporting an issue related with Raspberry Pi GPIO only - thanks for double click that you are using Azure IoT Edge Modules.
I found two related threads on StackOverflow:
- https://stackoverflow.com/questions/51769717/not-able-to-deploy-python-program-from-azure-iot-edge-to-rasberry-pi
- https://stackoverflow.com/questions/25845538/how-to-use-sudo-inside-a-docker-containerHave you tried it before?
provided below in the createOptions:
{ "HostConfig": { "Devices": [ { "PathOnHost": "/dev/gpiomem", "PathInContainer": "/dev/gpiomem", "CgroupPermissions": "rwm" } ] } }
- Proposed as answer by António Sérgio Azevedo - MSFTMicrosoft employee Monday, January 20, 2020 11:09 AM
- Marked as answer by nagamma_cdi Tuesday, January 21, 2020 12:21 PM
Monday, January 20, 2020 10:56 AM
All replies
-
Hello nagamma,
Thank you for your feedback! Please understand that this forum is to discuss Azure IoT Edge topics. Can you point us to the tutorial you are following and confirm that you are using Azure IoT Edge?
Thanks!
ASA
Friday, January 17, 2020 3:25 PM -
Thank you for your information. can you please tell me where I can put my queries related to Azure IoT Edge.Monday, January 20, 2020 4:43 AM
-
Hi,
If you are following a document and not able to complete the tutorial you can add an issue directly to the doc.
Here is also the suggested place to discuss Azure IoT Edge topics if they do not relate with a doc (as I believe is the case).
I have misread your question and thought you were reporting an issue related with Raspberry Pi GPIO only - thanks for double click that you are using Azure IoT Edge Modules.
I found two related threads on StackOverflow:
- https://stackoverflow.com/questions/51769717/not-able-to-deploy-python-program-from-azure-iot-edge-to-rasberry-pi
- https://stackoverflow.com/questions/25845538/how-to-use-sudo-inside-a-docker-containerHave you tried it before?
provided below in the createOptions:
{ "HostConfig": { "Devices": [ { "PathOnHost": "/dev/gpiomem", "PathInContainer": "/dev/gpiomem", "CgroupPermissions": "rwm" } ] } }
- Proposed as answer by António Sérgio Azevedo - MSFTMicrosoft employee Monday, January 20, 2020 11:09 AM
- Marked as answer by nagamma_cdi Tuesday, January 21, 2020 12:21 PM
Monday, January 20, 2020 10:56 AM -
It's worked for me .
Thank you sir.
Tuesday, January 21, 2020 6:14 AM