Tested on:RPi2, RPi3; Raspbian Stretch; Python3
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)
0

Docker and the Raspberry Pi: CherryPy in a Container

Docker is a program for modularized sharing of system resources and an efficient replacement of traditional virtual machines. For this, Docker gathers software with all its dependencies in a so-called Container. Containers can be moved from system to system and start without the installation of software besides Docker itself.
This tutorial shows how to create a Container with the Python webserver CherryPy on a Raspberry Pi.

Installation
The installation is performed with the smooth Installer-Script from Docker:

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

Docker and CherryPy
Docker gathers all files required for executing a minimal CherryPy webserver in a Container. app.py is the Python script for starting the server. The file requirements.txt contains the names of all dependencies, here just cherrypy. The Dockerfile is used for configuring the Container.
Create and run the Container by entering

After the server started, open a browser and browse to

CherryPy server in a Docker container

CherryPy server in a Docker container

CherryPy is very helpful, since it’s based on Python and gives access to the GPIO therefore. For example, CherryPy can be used to build browser-based remote controls for Raspberry Pi devices.

Full script
Click on Full Script to show all of the code.

Further Readings

Links
Docker Homepage: https://www.docker.com
Docker Installer-Script: https://docs.docker.com/install/linux/docker-ce/debian/
Wiki Docker: https://en.wikipedia.org/wiki/Docker_%28software%29
Tutorial CherryPy Raspberry Pi remote controls: http://www.knight-of-pi.org/cherrypy-an-elegant-python-webserver-for-raspberry-pi-remote-controls/

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.

Comment

Time limit is exhausted. Please reload CAPTCHA.