使用 docker build 后出现报错author: jwensh
date: 2021.12.28
The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
意思看着是: 发起 build 的时候请求的系统与当前主机系统版本不一致,且 build 的时候没有指定 platform
也就是说 docker build 可以加上 platform 参数,如: docker build -t tag:version -f Dockerfile --platform linux/amd64 .
注: x86_64,x64,AMD64基本可以理解为同一个平台技术
添加 --platform 后执行 build 依然出错似乎 --platform 没有生效,好像要开启 docker 的实验功能:experimental: ture
- 查看当前是否已经开启了 experimental : docker version -f '{{.Server.Experimental}}' 或者 docker info
- ture 则为打开了
- vim /etc/docker/daemon.json 添加
{ "experimental": true } - 重启 docker 服务: systemctl restart docker 问题解决
- https://docs.docker.com/engine/reference/commandline/build/#squash-an-images-layers—squash-experimental
- https://stackoverflow.com/questions/42494853/standard-init-linux-go178-exec-user-process-caused-exec-format-error



