Tested on:RPi3; Raspbian Stretch; Python3
Prerequisites:Raspberry Pi mit Raspbian Jessie und Internetverbindung (siehe Schritte 1-7 in der Einfuehrung)
Hardware:LED mit passendem Widerstand
2

Docker container with RPi.GPIO access for the Raspberry Pi

Accessing RPi.GPIO from within a Docker container on the Raspberry Pi requires some steps, as to be expected for a software like Docker that promises system independence.
Thanks to Alex Ellis for his plentiful resources about Docker & Raspberry Pi.

Docker Installation
Enter in the terminal

Turn the Raspberry Pi on again after it was fully shutdown.

Docker GPIO access
Now, the Docker Image for accessing the GPIO can be created with

Creating the Image takes a while. The base for this image (see Dockerfile) is the Docker image for Raspbian Stretch.

Test run
After executing

the LED attached to the RPi blinks. Exciting!

Stopping containers
Show all containers with

A container can now be stopped with its ID:

Links
Docker Raspbian Stretch Image: https://hub.docker.com/r/schachr/raspbian-stretch/
Tutorial Docker container: http://www.knight-of-pi.org/docker-and-the-raspberry-pi-cherrypy-in-a-container
Alex Ellis article Docker & GPIO: https://blog.alexellis.io/gpio-on-swarm/

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.

2 Comments

  1. If you want to perform GPIO with a different device, then you could adapt the code above or search to find out whether someone has already used sysfs in the library you’re using right now.

Comment

Time limit is exhausted. Please reload CAPTCHA.