在英特尔机器(Mac)上为ARM架构构建Docker映像 [英] Build Docker image for ARM architecture on Intel machine (Mac)

查看:317
本文介绍了在英特尔机器(Mac)上为ARM架构构建Docker映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的Mac上构建一个Docker的图像。我知道我可以使用QEMU在我的Mac上运行ARM容器,但是我不知道如何为ARM构建。

I'd like to be able to build a Docker image for ARM from my Mac. I know I can run ARM containers on my Mac using QEMU but I can't figure out how to build for ARM.

推荐答案

这是一个有点复杂的现在。我相信在不久的将来Docker将会更容易。

This is a little convoluted right now. I am sure it will be made easier by docker in the near future.

基本上你需要构建一个基于容器的包含qemu-arm-static二进制已经有了。

Basically you need to build a contained based on a container that has the qemu-arm-static binary in it already.

您可以通过查看 Raspberry Pi基础图像w / qemu-arm-static ,它直接用travis构建图像。

You can see how it is done by looking at Raspberry Pi base image w/qemu-arm-static which builds the images directly with travis.

我做了什么基本上是在我的raspberry pi构建我的基地码头图像与这个二进制添加并推到docker-hub。

What I did was basically on my raspberry pi build my base docker image with this binary added and push that to the docker-hub.

一旦我有这个图像作为我的基础,我可以建立并运行从它派生的容器,包括在我的OSX机器上构建新的派生容器,然后在我的raspberry pi的未修改的文件上运行。

Once I have that image as my base I can build and run containers that are derived from it, including building new derived containers, on my OSX machines and then run it on my raspberry pi's unmodified.

在我的raspberry pi我建立使用这个Docker文件的图像。我以冒险者的高山形象开始。您应该可以使用任何您想要的基本图像。

On my raspberry pi I build an image using this Dockerfile. I am starting with hypriot's base alpine image. You should be able to use any base image you want.

FROM hypriot/rpi-alpine-scratch

RUN apk update && \
apk upgrade && \
apk add bash && \
rm -rf /var/cache/apk/*

COPY qemu-arm-static /usr/bin/qemu-arm-static

CMD ["/bin/bash"]

一旦我推到Dockerhub我知道有一个容器我可以建立在我的intel机器上,并运行并构建在我的raspberry pi上。

Once I push that to Dockerhub I know have a container I can build based on on my intel machines and run and build on my raspberry pi's.

通过启动一个debian i386 docker容器,我得到了qemu-arm-static二进制文件, code> qemu-user-static 并复制二进制文件。

The qemu-arm-static binary I got by launching a debian i386 docker container, installing qemu-user-static and copying the binary out.

这篇关于在英特尔机器(Mac)上为ARM架构构建Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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