ERROR: failed to solve: nginx:1.16.0: failed to resolve source metadata for docker.io/library/nginx:1.16.0: failed to authorize: failed to fetch oauth token: Post "https://auth.docker.io/token": read tcp [2409:8a62:33d:44a1:dcca:c7af:87f8:6a1e]:50766->[2600:1f18:2148:bc00:41e1:f57f:e2e2:5e54]:443: read: connection reset by peer
更新于 阅读 20 次
运行docker build 时报如下错误
=> [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 547B 0.0s => ERROR [internal] load metadata for docker.io/library/xxx 0.5s => [auth] library/nginx:pull token for registry-1.docker.io 0.0s ------ > [internal] load metadata for docker.io/library/nginx:1.16.0: ------ Dockerfile:1 -------------------- 1 | >>> FROM --platform=linux/amd64 xxx 2 | ... 3 | -------------------- ERROR: failed to solve: nginx:1.16.0: failed to resolve source metadata for docker.io/library/xxx: failed to authorize: failed to fetch oauth token: Post "https://auth.docker.io/token": read tcp [2409:8a62:33d:44a1:dcca:c7af:87f8:6a1e]:50766->[2600:1f18:2148:bc00:41e1:f57f:e2e2:5e54]:443: read: connection reset by peer
直接添加如下配置
export DOCKER_BUILDKIT=0 export COMPOSE_DOCKER_CLI_BUILD=0
DOCKER_BUILDKIT=0:禁用 Docker BuildKit。BuildKit 是 Docker 引入的新的构建系统,提供了更快和并行化的构建。但在某些情况下,禁用它可以帮助解决兼容性问题或错误。
COMPOSE_DOCKER_CLI_BUILD=0:禁用使用 Docker CLI 构建的特性,而恢复使用 docker-compose 自带的构建流程。
通过将这两个变量设置为 0,您可以绕过某些在启用了 BuildKit 和 Docker CLI 构建时出现的问题,使得构建过程能够顺利进行。
如果禁用这两个功能后可以正常 build,说明可能是 Docker BuildKit 或 Docker CLI 的某些特性与当前环境或项目配置不兼容。