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.