![如何修复使用 Docker 时出现的“ERROR [internal] load metadata for docker.io”错误?](https://linux22.com/image/785577/%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%E4%BD%BF%E7%94%A8%20Docker%20%E6%97%B6%E5%87%BA%E7%8E%B0%E7%9A%84%E2%80%9CERROR%20%5Binternal%5D%20load%20metadata%20for%20docker.io%E2%80%9D%E9%94%99%E8%AF%AF%EF%BC%9F.png)
我正在我的 MacOS 上编译一个基于 Cosmos 的区块链项目的源代码。该项目使用 Docker。我安装了 Docker,它似乎运行正常。但在编译时,我收到了与 Docker 相关的以下消息:
[+] Building 0.3s (2/3)
[+] Building 0.4s (3/3) FINISHED
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 719B
=> [internal] load .dockerignore
=> => transferring context: 2B
=> ERROR [internal] load metadata for docker.io/library/golang:1.20.1-alpine3.17
------
> [internal] load metadata for docker.io/library/golang:1.20.1-alpine3.17:
------
Dockerfile:1
--------------------
1 | >>> FROM golang:1.20.1-alpine3.17
2 |
3 | WORKDIR /
--------------------
ERROR: failed to solve: error getting credentials - err: exit status 1, out: ``
有人能帮我找到解决办法吗?
答案1
尝试"credsStore": "desktop.exe"
按照~/.docker/config.json
此处的建议删除https://github.com/docker/buildx/issues/476。我遇到了FROM php:7.4-apache
同样的错误消息,而 credsStore 修复对我有用。
编辑:
"credsStore": "desktop"
在 Mac 上
答案2
我通过在命令末尾添加 --platform="linux/amd64" 解决了在 MAC 上运行 docker build 命令时遇到的这个问题。