Docker - 在Mac上构建rpi图像 [英] Docker - Build rpi image on Mac

查看:296
本文介绍了Docker - 在Mac上构建rpi图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是更通用的,并且正在使用机器架构A构建架构B的映像。我目前想要创建具有大量Python依赖关系的映像。这需要时间在raspberry-pi,但在Mac上更快。当我得到一个错误在最后需要重建。有没有办法在Mac上构建这个图像,然后把它放在我的raspberry pi上?

解决方案

模拟完整的备用架构一般很慢 QEMU 是什么让您在Linux上执行此操作,可以集成到Docker容器中。



对于构建,您可以使用 QEMU用户仿真,比完全仿真快得多。这允许您的硬件直接执行ARM二进制文件,并用于简化交叉编译和交叉调试。



第一个获取VirtualBox 获取Vagrant 并安装。 (或使用 docker-machine Docker工具箱



设置您的VM

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

现在你在你的Debian Linux VM上,设置Docker主机

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

运行raspbian环境

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

并做你所需要的。



然后,您可以 docker export docker import 来移动图片。您还可以使用中心设置注册表使用 push /



Docker Toolbox 还将允许您通过Mac上的VirtualBox VM轻松地运行Docker,但是遇到更多的麻烦,而不是值得(当您有流氓安装时)。 / p>

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 ?

解决方案

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).

这篇关于Docker - 在Mac上构建rpi图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆