Uniform Development by Docker & QEMU




About: Docker.Taipei 共同發起人 碁峰《Docker入門與實戰》審閱者 Acer eDC, 玉山銀行資訊處, 臺北榮民總醫院 Java/Web Developer, Image Processing, Software Engineering, Algorithmic Trading, Docker

Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.

QEMU is a generic and open source machine emulator and virtualizer.

Combine Docker and QEMU to run Raspbian on X86 or AMD64 platform, and build Docker image include your program that can run on RPi (ARMv6) and RPi 2 (ARMv7).

Step 1: Install Docker & QEMU on Linux

I use Ubuntu to demo this project.

Install Docker on Ubuntu:

curl -sSL https://get.docker.com/ubuntu/ | sudo sh

Insatll QEMU on Ubuntu:

sudo apt-get install qemu-user-static

Step 2: Run Raspbian on X86

Pull RPi Raspbian image of Docker

sudo docker pull philipz/rpi-raspbian:latest

sudo docker run -it --rm -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static philipz/rpi-raspbian bash

Step 3: Write Once, Run Anywhere

Dockerizing any program of linux system, it can run anywhere.

In Arch Linux on RPi install Docker.

pacman -S docker

Build Docker images of your program. This is the "Hello World" example of Mono application, first run on RPi (ARMv6). Then it run on RPi 2 (ARMv7), also run on X86 finally.

So we could portable program on RPi, RPi 2, and PC by Docker.

Step 4: Example - Run RPi XRDP Application on X86

The other example is XRDP (Remote Desktop) of RPi.

sudo docker run -it --rm -p 3389:3389 -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static philipz/raspbian-xfce:latest bash

Then open Remote Desktop Client to connect the XRDP of RPi on X86.




    • Classroom Science Contest

      Classroom Science Contest
    • Fandom Contest

      Fandom Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest

    8 Discussions


    4 years ago on Introduction

    Hi, very interesting idea. I've recently needed to compile something for RPi2 but it took long hours. This should help, am I right?

    But I have a problem. I've installed qemu-user-static on Arch Linux:
    $ yaourt -S qemu-user-static

    Then I've check /usr/bin/qemu-arm-static exists:
    $ ls /usr/bin/qemu-arm-static

    But when I run docker run, I get following:
    $ docker run -it --rm -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static philipz/rpi-raspbian bash

    exec format errorFATA[0002] Error response from daemon: Cannot start container e9365e9e099c2615326b3f8cad3a1dcab3a77bc8b530f015a0b1b4d6df4eabae: exec format error

    I'm not sure if I'm doing something wrong. Could you help me, please? :-)

    $ uname -a

    Linux jprokop-ntb 3.18.6-1-ARCH #1 SMP PREEMPT Sat Feb 7 08:44:05 CET 2015 x86_64 GNU/Linux

    4 replies

    Reply 4 years ago on Introduction

    I tried to run it in Ubuntu 14.04 with qemu-arm-static 2.0.0 and it's running. So it seems that it could be cause by version or maybe I have something wrong in my Arch Linux...

    Anyway, can you describe me what's exactly inside your container? What does the trick? In which architecture are binaries compiled in philipz/rpi-raspbian? How does work providing of /usr/bin/qemu-arm-static through volume? Does it mean that bash command is somehow run by this binary?

    Thanks once again :-)


    Reply 4 years ago on Introduction

    Hi, This philipz/rpi-raspbian is no different with others of Docker Hub RPi images. And it was auto-build from my Github project.


    So, you would pull resin/rpi-raspbian, and use the same method to run on X86 PC. But, this method only to static binary file, other dynamic linking execute file, like java or go, will response error.


    Reply 4 years ago on Introduction

    Thank you for the link.

    My version of qemu-arm is 2.2.0, can this be a problem?

    Should I try to recompile .tar.xz image by ./mkimage-raspbian.sh and then create new docker image?

    Thanks for help.


    4 years ago on Introduction

    Cool tutorial, runs like a breeze!

    I just used this commands to setup a new Vagrant Ubuntu box with your given ideas above:

    curl -sSL https://get.docker.com/ubuntu/ | sudo sh
    sudo apt-get update
    sudo apt-get install -y qemu-user-static
    sudo usermod --groups docker vagrant

    The last command grants your user "vagrant" to the group "docker". Then you never need a "sudo" to run any of the docker commands! This is really handy and saves some time...

    1 reply

    4 years ago on Introduction

    This is interesting. I've never done anything with Docker or QEMU but I think I'll try in the future.