x86机器上运行arm64 docker

匿名 (未验证) 提交于 2019-12-02 23:43:01

Docker Hub 上可以找到各种非 x86_64 平台的镜像,但是在x86上直接运行会报错:

panic: standard_init_linux.go:175: exec user process caused “exec format error” [recovered]

在 x86_64 平台上缺少运行 arm32v7 的 Python 解释器所需要的“环境依赖”,值得庆幸的是在 Linux 上我们可以用 QEMU 来做到跨平台运行,QEMU 的 User-mode emulation 对于容器技术来说是最适合的模式。

https://juejin.im/post/5af86fb15188251b8015c102

步骤

  1. https://github.com/multiarch/qemu-user-static/releases 下载qemu-xxx-static文件,注意要根据自己平台选择,如arm64是qemu-aarch64-static,arm32是qemu-arm-static,选错文件后面的步骤会失败。
  2. 拷贝文件
    sudo cp qemu-aarch64-static /usr/bin/ chmod +x /usr/bin/qemu-aarch64-static 
  3. 运行命令
    docker run --rm --privileged multiarch/qemu-user-static:register 
    这个提示可以忽略:

    Setting /usr/bin/qemu-alpha-static as binfmt interpreter for alpha
    sh: write error: Invalid argument

  4. 运行docker
    docker run -it -v /usr/bin/qemu-aarch64-static:/usr/bin/qemu-aarch64-static arm64v8/ubuntu 
文章来源: https://blog.csdn.net/xiang_freedom/article/details/92724299
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!