[英]exec format error when building docker image from arm32v7 golang image
I am trying to build a docker image FROM arm32v7/golang:1.13.4-alpine
which I was successfully build from a mac but when I try to build it on a linux machine, it throws an exec format error
.我正在尝试从arm32v7/golang:1.13.4-alpine
构建 docker 映像,我是从 mac 成功构建的,但是当我尝试在 linux 机器上构建它时,它会引发exec format error
。 There so many questions on exec format error
but couldn't find any solution.关于exec format error
有很多问题,但找不到任何解决方案。 My docker file looks like below我的 docker 文件如下所示
FROM arm32v7/golang:1.13.4-alpine as staging
RUN .....
RUN .....
RUN tar -czvf sbuild.tar.gz ./servicebuild
......
......
CMD tar -xzvf sbuild.tar.gz && ./servicebuild
It basically fails at the first command in the docker file throwing an error standard_init_linux.go:211: exec user process caused "exec format error"
它基本上在 docker 文件中的第一个命令处失败,抛出错误standard_init_linux.go:211: exec user process caused "exec format error"
Architecture of the build machine Linux x86_64 x86_64 x86_64 GNU/Linux
构建机器Linux x86_64 x86_64 x86_64 GNU/Linux
的架构
Is arm32v7 not supported on the above architecture?上面的架构不支持arm32v7吗? Is there any other way I could do this?有没有其他方法可以做到这一点?
It's because Docker for Mac supports multi-CPU architecture: https://docs.docker.com/docker-for-mac/multi-arch/这是因为 Docker for Mac 支持多 CPU 架构: https://docs.docker.com/docker-for-mac/multi-arch/
As far as I know, on Linux using native Docker you don't have that.据我所知,在 Linux 上使用本机 Docker 你没有那个。 Although you might be able to do it by installing extra software.尽管您可以通过安装额外的软件来做到这一点。 Checkout this post for example: https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408例如查看这篇文章: https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408
You need to enable execution of different multi-architecture containers by QEMU and binfmt_misc.您需要通过 QEMU 和 binfmt_misc 启用不同的多架构容器的执行。
In recent distro this can be simply done by running:在最近的发行版中,这可以通过运行简单地完成:
apt-get install qemu-user-static
If this doesn't work for you, you can execute:如果这对您不起作用,您可以执行:
docker run --rm --privileged multiarch/qemu-user-static --reset --persistent yes --credential yes
Note that this may reconfigure any existing binfmt_misc setup that you have.请注意,这可能会重新配置您拥有的任何现有 binfmt_misc 设置。 See https://github.com/multiarch/qemu-user-static for more detail.有关详细信息,请参阅https://github.com/multiarch/qemu-user-static 。
This information is available in one alpine repositories README but not on the wiki as far as I know: https://gitlab.alpinelinux.org/alpine/docker-abuild#configure-multi-arch-support此信息可在一个 alpine 存储库 README 中找到,但据我所知不在 wiki 上: https://gitlab.alpinelinux.org/alpine/docker-abuild#configure-multi-arch-support
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.