Docker for ARM, Python3 and PyQt5

Docker, Docker everywhere… you open the fridge and.. docker with butter and cheese, Docker may save the day but it may also make it horrible… But it doesn’t matter if you like it or not. Docker is here, its containers are everywhere. So lets join the flow 🙂

We will dockerize ProxyLCD in CLI mode. No more running the app manually:) Laziness !


We will write a Dockerfile and publish it on docker hub. But before that lets think what our app needs. It needs OS, ubuntu:latest seems a good choice. Next we need Python3 and here we have two choices, use base image and add python manually or find a good python3 image. I opt for second one.
Next we need to get code from github and put it into container. Almost there, now install required libs and finally run an entrypoint to start proxylcd in cli mode.

Docker @Raspberry Pi

I heard that docker is available on Raspberry, its amazing that so small device can run such big app:) But there is one catch. We can only use images for arm:(
Installation is simple just run:

sudo curl -sSL | sh

few mites PUF and it is done.
Do not forget to add pi user to docker group:

sudo usermod -aG docker pi

Remember to relog user and type:

docker run armhf/hello-world

to see if it is working.

This image is an arm one, sadly running

docker run hello-world

fails 😦
This is something we need to keep in mind all the time. Using arm image on arm and x64 on rest.


This is tricky. Normally I would use some python3 image. But we have an arm architecture. Lets look if we can find something useful…
Yes we can:) There are is armhf/python container. Lets take it as a base and create our own image.
Creating of image we will split into few parts. First we will create python and install required libraries. Next we will work on how to get files from github, unpack them and run app.

Base image

I made two files, requirements.txt, copied from ProxyLCD:


and with imports and hello world:

import sys

import getopt
import signal
import charlcd
import iot_message

from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QCoreApplication

print("hello world")

Our goal: build image and run it. Oh yes, build, I forgot about Dockerfile:

FROM armhf/python:3.5
RUN mkdir /app
ADD . /app
RUN pip3 install -r requirements.txt
CMD [ "python", "./" ]

This is our start point. But it fails miserably at pip3 install, pyqt5 is not available from pypi to arm architecture.
So lets install it from repository by adding:

RUN apt-get update \
    && apt-get -y install python3-pyqt5

just after FROM.
Now pyqt5 installs from repo but pip still fails, it tries to install pyqt from pypy but it is not possible. I hoped that we can use requirements.txt to install required libraries. But in such situation.. we have to install each lib manually.
This was the begining of all bunch of problems.. PyQt was working with python3.4 but pip fails with old error, I couldn’t make it work.
So lets move upstream to container source:) If we cannot make it work we can create new image from pure debian. New Dockerfile:

FROM armhf/debian

RUN apt-get update \
    && apt-get -y install python3 \
    python3-pyqt5 \
    python3-pip \
    python3-dev \

RUN mkdir /app

RUN pip3 install charlcd \
    && pip3 install iot_message

ADD . /app
CMD [ "python3.4", "./" ]

And we have first success ! It worked! It took very long time on my Raspberry Pi but it was a success.
We have a working python3.4 container. Before we move on lets make it more universal and publish it.

Your own container @ docker hub

Lets look at the process of adding own container to repository. First you have to register 🙂
Next we need to tweak a little bit our Dockerfile, we need to remove last two lines, with Add and CMD.
Now we need to build our container:

docker build .

It should end with

Successfully built f80251f76285

For you hash will be different. Next step is to add tag:

docker tag f8025 bkosciow/rpi-qtpython

Login to dockerhub:

docker login

and finally

docker push bkosciow/rpi-qtpython

We have our new shiny image. We can refactor Docker file with sample:

FROM bkosciow/rpi-qtpython

ADD . /app
CMD [ "python3.4", "./" ]

Nice 🙂


Ok I will stop now. Getting files from GitHub is reserved for part 2:)
I’m sure that now you can build your own image and publish it to docker hub.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s