Docker – Build rpi image on Mac

This could be more generic and be building an image for architecture B with a machine architecture A. I currently want to create an image with lot of Python dependencies. Which take time on raspberry-pi but is faster on Mac. When I get an error at the end well need to rebuild. Is there a way to build this image on Mac and then pull it on my raspberry pi ?

  • Docker: Staging multiple containers for one application
  • Microservices on docker - architecture
  • How do I install Docker on an NVIDIA Tegra Jetson TK1 with a 32 bit ARM processor running Ubuntu 14.04?
  • Where does Elixir/erlang fit into the microservices approach? [closed]
  • What is the concept of Ambassador in distributed systems?
  • In microservice, how do you make sure that all services get updated when more than one micro service is affected?
  • how to reach another container from a dockerised nginx
  • Spring Cloud service Look up error: Load balancer does not have available server for client
  • windows docker pull EOF
  • Properly automate a docker script in Python
  • Docker - how to cache added directory?
  • dockerizing wordpress with mysql installed on the host machine
  • 2 Solutions collect form web for “Docker – Build rpi image on Mac”

    Emulating a full alternate architecture is generally very slow. QEMU is what allows you to do this on Linux and can be integrated into a Docker container.

    For building, you can use QEMU User Emulation which is much quicker than full emulation. This allows your hardware to execute ARM binaries directly and is used to ease cross-compilation and cross-debugging.

    First get VirtualBox and get Vagrant and install. (Or use docker-machine from the Docker Toolbox)

    Setup your VM

    mkdir raspbian-docker
    cd raspbian-docker
    vagrant init debian/jessie64
    vagrant up
    vagrant ssh
    

    Now you are on your Debian Linux VM, setup the Docker host

    sudo su -
    apt-get install qemu-user-static
    curl https://get.docker.com/ | sh
    

    Run a raspbian environment

    docker run -ti \
      --volume /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static \
      philipz/rpi-raspbian \
      bash
    

    And do what you need to.

    Then you can docker export and docker import to move images around. You can also use the hub or setup a registry to use push/pull

    The Docker Toolbox will also allow you to easily run Docker via a VirtualBox VM on mac but I’ve run into more troubles than it’s been worth (when you have vagrant setup).

    You can fork RPI’s distro builder and customise for your needs: https://github.com/RPi-Distro/pi-gen
    It uses qemu-debootstrap on Docker, similar to as Matt’s answer.

    If you plan to also build Docker images for arm architecture, qemu-debootstrap won’t help. In this case you can run Docker builds directly on an ARM server, such as the ones offered by Scaleway.

    My CI server runs a combination of the above, to continuously build a OS image with pre-loaded armh docker images. Then, device-init takes care of loading docker exports as docker images.
    The downside is that device-init can take hours to pre-load the docker images, after first boot.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.