docker build失败记录

2023-06-30  本文已影响0人  有时右逝

背景

需要在debian下打包一个Python脚本,打算基于docker来打包。debian是 armv8架构的。
我编写了dockerfile,但是失败了。环境是mac电脑

过程

 => ERROR [internal] load metadata for docker.io/arm64v8/debian:latest                                                                                                       154.3s
------
 > [internal] load metadata for docker.io/arm64v8/debian:latest:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests latest]: 400 Bad Request

经过无数次搜索,最终的结论是官方问题。

解决方法就是 执行 docker build 前 加上 DOCKER_BUILDKIT=0

要么升级docker desktop最新版本

编译过程太慢了,主要是网络慢。

1、尝试在docker desktop中配置代理,无效。
2、尝试修改本地配置文件。~/.docker/config.json 。有效果。但是代理地址不能使用127.0.0.1 必须使用本机的局域网ip地址。如果局域网地址变了,则每次都需要更改,无意义。
例如我本机是clashx,如下代码添加到 config.json中。注意替换127.0.0.1

"proxies":{
   "default":
   {
     "httpProxy": "http://127.0.01:7890",
     "httpsProxy": "http://127.0.01:7890",
     "noProxy": "localhost,127.0.0.1,.example.com"
   }
 }

这地方估计存在官方问题,docker build 的默认network 应该是host 理论上应该可以使用127.0.0.1的。但是不知道为何不行。

  1. 使用环境变量。
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890

再执行docker build 会自动使用代理。
如果需要一直有效,则写入 ~/.bashrc 文件即可。

上一篇 下一篇

猜你喜欢

热点阅读