Friday, October 09, 2015

Having my cake and eating it ... OSMC (Kodi on Raspberry Pi) and Hypriot/Docker

I was really pleased when Hypriot started producing images to run Docker on the Raspberry Pi.

In case you don't know Docker which provides amongst other things great application portability only runs natively on Linux/x86-64 ... (OK, let's ignore that Microsoft have ported Docker to their Technical Preview of Windows Server 2016 - for the moment the only official deployable Docker runs on Linux/x86-64).

Hypriot's Docker port
But there have been several ports of Docker to other architectures such as the ARM-processor based Raspberry Pi.  Hypriot have been producing SD-card images for a while now to allow to install/run a specific distribution including their build of Docker.  I had a chance meeting with Dieter Reuter of Hypriot at DockerCon SF in June ... I was surprised to find that they're a group of volunteers in Germany building these images in their spare time.  They've also been gradually including other components of the Docker ecosystem on Raspberry Pi such as Docker Machine, Docker Compose and Docker Swarm.

You can read more about their latest release 'Will' on their blog here 'HypriotOS Reloaded'

I also run media software on my Raspberry Pi in the form of OSMC (a Raspberry Pi specific derivation of Kodi - previously known as XBMC or XBox Media Center).  OSMC is written by Sam Nazarko.

Choosing between my media center and my Docker demo
But a man only has so many Raspberry Pi's and so I kept switching between my media center software OSMC and Hypriot's Docker which I sometimes used for Docker demos as part of an OpenStack training at work.

So a month or so ago I posted on the site asking if it was possible to add Docker support.
As my "media center" Raspberry Pi is also used for some web-scraping cron jobs (using my Not invented here scraper) I was hoping I could use the same machine for my media center, docker demos or other experiments and for my web-scraping (which would be run under Docker ... why not!).

I was very pleasantly surprised by the very quick reply from Sam suggesting he should be able to include kernel support for Docker in the OSMC September release.

OSMC and Hypriot's Docker
So today I realized that OSMC does not include kernel support for Docker.
This evening I downloaded the latest OSMC release and wrote that to a uSDHC card, booted up and then installed the Hypriot Docker 1.8.2 Debian package available from their download page.
Without more a do I had Docker up and running on my OSMC.
To check I pulled and ran the Hypriot supplied hypriot/rpi-node image from DockerHub ... success!


Installation instructions

Here are some fairly rough instructions of what I did, which can be resumed as
- Perform a standard OSMC install to a uSDHC card
- Install the Hypriot Docker debian package

To start with I downloaded the latest OSMC release (2015.09-2 for RaspberryPi 2) from their download page.
As I'm running Windows I used Win32 Disk Imager to write to a 32GBy uSDHC card (you can get away with much smaller ~ 2 or 4GBy I think).

I then booted the Raspberry.
On reboot I
- logged in as user osmc (with password osmc)
- added a new user, and installedan  ssh-key to the Raspberry using ssh-copy-id from my Windows machine (I run cygwin).
- Still as osmc I gave sudo permissions to my new user by adding a line to /etc/sudoers
    sudo vi /etc/sudoers
    Adding the line
        user     ALL=(ALL:ALL) ALL
-  I also edited /etc/group to add my user as a member of group docker.
- I then rebooted

On reboot I performed
    docker ps
to see that I could communicate correctly with the Docker daemon:
    $ docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS  NAMES

This shows that we can communicate with the Docker daemon and that we have no containers running.

I then ran one of the Hypriot Docker images from the Docker Hub and landed in a shell within the container.

    $ docker run -it hypriot/rpi-node bash


Next step install some images (see below) and start playing ...

You can download Hypriots SD-card images for Raspberry Pi, or their individual debian packages here:

You can download OSMC from the download page here
Currently it's the 2015.09-2 image which you want.

Running Hypriot provided Docker images for the Raspberry
Hypriot have provided several Docker images on the DockerHub for the Raspberry Pi.

Note: As this is an ARM architecture we require specific ARM architecture images.

We can search for Hypriot images on the Docker Hub as follows:
$ docker search hypriot/rpi
NAME                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
hypriot/rpi-node               RPi-compatible Docker Image with Node.js        24
hypriot/rpi-java               RPi-compatible Docker Image with Java           13
hypriot/rpi-python             RPi-compatible Docker Image with Python         12
hypriot/rpi-iojs               RPi-compatible Docker Image with io.js          11
hypriot/rpi-golang                                                             9
hypriot/rpi-gogs-raspbian      Raspberry Pi compatible Docker Image with ...   7
hypriot/rpi-gpio               Dockerized gpio binary of wiringPi for the...   6
hypriot/rpi-busybox-httpd      Raspberry Pi compatible Docker Image with ...   6
hypriot/rpi-ruby               RPi-compatible Docker Image with Ruby           5
hypriot/rpi-mysql              RPi-compatible Docker Image with Mysql          4
hypriot/rpi-hugo               Raspberry Pi compatible Docker Image with ...   4
hypriot/rpi-drone              Raspberry Pi compatible Docker Image with ...   3
hypriot/rpi-crate              RPi-compatible Docker Image with       3
hypriot/rpi-swarm              Raspberry Pi compatible Docker image with ...   3
hypriot/rpi-haproxy            Haproxy Dockerfile                              2
hypriot/rpi-redis              Raspberry Pi compatible redis image             2
hypriot/rpi-alpine-scratch     Raspberry Pi compatible Docker Image with ...   2
hypriot/rpi-gogs-alpine        Raspberry Pi compatible Docker Image with ...   1
hypriot/rpi-tor-relay                                                          1
np83/rpi2-hypriot-nodejs       Raspberry PI 2 can run hypriot Docker host...   0                    [OK]
gdelpu/rpi-hypriot-node-hapi   NodeJs with HapiJs framework                    0
hypriot/rpi-nano-httpd         Raspberry Pi nano sized HTTP server             0
hypriot/rpi-skydns                                                             0

Lines above commencing with hypriot/ are hypriot provided images.

What next?
I saw a post somewhere of someone running Jupyter on the Raspberry Pi ... I must give that a try ...

No comments:

[Conference -] Developing Micro-services on Kubernetes

In April I had the chance to present at , first in Warsaw on Apr 24th, and then in Wroclaw ("wroslof" was my best at...