简体   繁体   English

从 arm32v7 golang 映像构建 docker 映像时执行格式错误

[英]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.

相关问题 如何在高山Linux中获得docker体系结构,例如amd64,arm32v7? - How to get docker architecture, like amd64, arm32v7, in alpine linux? 在 ARM64 上构建 docker 映像时出错 - Error while building docker image on ARM64 运行 Docker 图像 ros:k.netic 时出现问题(standard_init_linux.go:211:exec 用户进程导致“exec 格式错误”) - Problem when running Docker image ros:kinetic (standard_init_linux.go:211: exec user process caused "exec format error") 如何为 Oraclelinux 8 arm64v8 创建 Docker 映像 - How to create a Docker image for Oraclelinux 8 arm64v8 在构建 Docker 映像时安装 Anaconda 和软件包 - Install Anaconda and Packages When Building Docker Image 从 pytorch/manylinux-cpu 基础映像构建 docker 映像时如何安装 apt-get? - How to install apt-get when building docker image from pytorch/manylinux-cpu base image? 尝试运行 Docker 映像时出现“exec 用户进程导致“没有这样的文件或目录”错误 - Getting "exec user process caused "no such file or directory"" error when trying to run Docker image lstate错误:使用Docker构建命令从自定义映像构建Docker时没有这样的文件或目录 - lstate error: no such file or directory while building Docker from a custom image with Docker build command 从多个 docker hub 镜像或私有 repo docker 构建镜像 - Building image from multiple docker hub images or private repo docker "Docker Alpine:无法选择包:python(没有这样的包)同时为 ARM 构建映像" - Docker Alpine: unable to select packages: python (no such package) while building image for ARM
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM