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

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

问题描述

这可能更通用,并且为具有机器架构 A 的架构 B 构建映像.我目前想创建一个具有大量 Python 依赖项的映像.这在 raspberry-pi 上需要时间,但在 Mac 上速度更快.当我最后收到错误时,需要重建.有没有办法在 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 ?

推荐答案

模拟一个完整的替代架构通常很慢.QEMU 允许您在 Linux 上执行此操作并且可以集成到 Docker 容器中.

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.

对于构建,您可以使用 QEMU User Emulation,这要快得多而不是完全模拟.这允许您的硬件直接执行 ARM 二进制文件,并用于简化交叉编译和交叉调试.

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.

首先获取 VirtualBox获取 Vagrant 并安装.(或者使用 docker-machine 来自 Docker 工具箱)

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

设置您的虚拟机

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

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

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

运行 raspbian 环境

Run a raspbian environment

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

然后做你需要做的事.

然后你可以docker exportdocker import 来移动图像.您还可以使用 中心设置注册表以使用push/

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

Docker Toolbox 还允许您在 mac 上通过 VirtualBox VM 轻松运行 Docker但我遇到的麻烦比它值得的多(当你有流浪汉设置时).

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天全站免登陆