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

问题描述

我希望能够从我的 Mac 为 ARM 构建 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.

您可以通过查看 带有 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.

我所做的基本上是在我的树莓派上构建我的基础 docker 镜像,并添加这个二进制文件并将其推送到 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 机器上构建和运行从它派生的容器,包括构建新的派生容器,然后在未修改的树莓派上运行它.

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.

在我的树莓派上,我使用这个 Dockerfile 构建了一个镜像.我从 hypriot 的基本高山图像开始.你应该可以使用任何你想要的基础镜像.

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,我就知道有一个容器可以基于我的英特尔机器构建并在我的树莓派上运行和构建.

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-user-static 并复制二进制文件得到的 qemu-arm-static 二进制文件.

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

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

05-18 13:49