Build an Docker image with Mac M1, push it to Docker Hub : can not use that image on Win 10

huangapple go评论51阅读模式
英文:

Build an Docker image with Mac M1, push it to Docker Hub : can not use that image on Win 10

问题

docker: 守护程序返回错误响应:找到映像 qwerty22/kube-kompose:pok-0 但与指定平台不匹配:期望为 windows/amd64,实际为 linux/arm64。

这对我来说是新的。我以为 Docker/标准映像是“通用的”。但现在似乎需要为每个平台构建一个映像以便运行?

示例映像是来自 [https://github.com/kubernetes/kompose] 的 kubernetes-kompose。

编辑:我试图在 Win 10 和 Docker 桌面上运行该映像。

所以问题是:我能否在我的 Mac 上构建一个 Docker 映像,将映像推送到 Docker Hub,然后将其拉到 Win 10 上并在那里运行?

我似乎在那方面没有成功。

英文:
docker: Error response form daemon: image witn reference qwerty22/kube-kompose:pok-0 was found but does not match the specified platform: wanted windows/amd64, actula : linux/arm64.

This was new to me. I thought Docker/standard images are "universal". But now it seems that you need to build an image for each platform - to run on ?

Example image was kubernetes-kompose from [https://github.com/kubernetes/kompose]

EDIT: I was trying to run that image on Win 10 and Docker desktop.

So the question is: Can I build a Docker image with my Mac, push the image to Docker Hub, pull image to a Win 10, and run it there?

I did not seem to succeed on that.

答案1

得分: 3

操作系统的构建和运行架构必须兼容。

你应该在Docker桌面上启用Linux容器。要做到这一点,右键单击Docker桌面图标,然后从菜单中选择“切换到Linux容器”。
有关更多详细信息,请查看此指南

另一种方法是在你的Mac M1上为amd64构建镜像,方法如下:

docker buildx build --platform linux/amd64 --push -t <registry>/<project-id>/<image>

因为使用Apple Silicon构建的Docker镜像是基于ARM架构的,这可能在部署镜像到Linux或基于Windows的amd64环境时引发问题。

英文:

The OS architecture of the build and the run must be compatible.

You should turn on Linux containers on Docker desktop. To do that, right-click on Docker desktop icon and select Switch to Linux Containers from the menu.
For more details check this guide.

Another way is to build the image on your Mac M1 for amd64 like this:

docker buildx build --platform linux/amd64 --push -t &lt;registry&gt;/&lt;project-id&gt;/&lt;image&gt;

because the docker images built with Apple Silicon are ARM-based architecture and this can create issues when deploying the images to a Linux or Windows-based amd64 environment.

huangapple
  • 本文由 发表于 2023年5月25日 04:51:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76327315.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定