在 Moby 中使用 make binary 命令时,遇到了以下错误:

=> CANCELED [internal] load metadata for docker.io/library/golang:1.20.3-bullseye                                                                   0.6s

=> ERROR [internal] load metadata for docker.io/tonistiigi/xx:1.2.1                                                                                 0.6s

------

 > [internal] load metadata for docker.io/tonistiigi/xx:1.2.1:

------

Dockerfile:16

--------------------

  14 |     

  15 |     # cross compilation helper

  16 | >>> FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx

  17 |     

  18 |     # dummy stage to make sure the image is built for deps that don't support some

--------------------

ERROR: failed to solve: tonistiigi/xx:1.2.1: failed commit on ref "unknown-sha256:e139b86ca7465f8d456a8fdbaacec253201a31c4ee47aab5d828d36ea2a6a997": "unknown-sha256:e139b86ca7465f8d456a8fdbaacec253201a31c4ee47aab5d828d36ea2a6a997" failed size validation: 9166 != 8838: failed precondition

这个错误可能是由于 tonistiigi/xx 镜像的某个 layer 下载或验证失败导致的。

解决方法

1. 清除本地镜像缓存

清除本地镜像缓存的命令为:

docker system prune -a

这将删除所有未被使用的镜像、容器和网络等资源,并清除所有本地镜像缓存。

2. 重新构建

清除缓存后,重新构建:

make binary

3. 手动拉取镜像

如果问题仍然存在,可以尝试手动拉取 tonistiigi/xx 镜像并重新构建:

docker pull tonistiigi/xx:1.2.1
make binary
Moby 中使用 make binary 报错:`failed commit on ref` 解决方法

原文地址: https://www.cveoy.top/t/topic/fYMG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录