在 Windows Server 2019 上为 Linux 构建 docker 映像失败

发布于 2025-01-15 08:21:37 字数 870 浏览 2 评论 0 原文

我们正在构建一个 .net 5.0 gRPC 服务,并使用以下命令尝试在我的开发机器(带有 Docker Desktop 的 Windows 10)上为 Linux 创建 docker 映像,效果很好:

docker build --platform=linux 。 -t repo:imagename --no-cache

问题是我们的 CI/CD 管道使用 Windows Server 2019 并且无法安装 Docker 桌面,所以我按照以下步骤操作:

Docker Linux 容器在 Windows Server 2019 上运行

,这似乎可以在服务器上运行 Linux 映像,但不能构建它们?这可能吗?

docker 版本给出:

在此处输入图像描述

您可以看到 docker 服务器的操作系统/Arch 是 windows,甚至使用 lcow 也无法将其变为 linux,

因此构建会出现以下错误:

无法获取目标图像“sha256:guid”:找到了引用 sha256:guid 的图像,但与指定的平台不匹配:想要 linux/amd64,实际:windows/amd64

感谢任何帮助

We are building a .net 5.0 gRPC service and using the below command trying to create docker image for linux on my dev machine (windows 10 with Docker Desktop) works just fine:

docker build --platform=linux . -t repo:imagename --no-cache

the issue is that our CI/CD pipeline uses windows server 2019 and Docker desktop cannot be installed, so I followed this:

Docker Linux Container running on Windows Server 2019

and that seems to work to run linux images on the server but not to build them? Is this even possible?

docker version gives:

enter image description here

you can see that the OS/Arch is windows for the docker server and even using lcow cannot get it to be linux

so building gives the following error:

failed to get destination image "sha256:guid": image with reference sha256:guid was found but does not match the specified platform: wanted linux/amd64, actual: windows/amd64

Any help is appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文