![](/img/trans.png)
[英]How to get docker architecture, like amd64, arm32v7, in alpine linux?
[英]Error running docker build for arm32v7 container on amd64 linux machine: standard_init_linux.go:207
我有一台 amd64 linux 機器,我用它來構建 arm32v7 容器。 當docker build
遇到第一個 RUN 命令時,它會出錯:
standard_init_linux.go:207: exec user process caused "no such file or directory"
通過在 amd64 linux 主機上docker run -it arm32v7/ubuntu:xenial
,可以在沒有docker run -it arm32v7/ubuntu:xenial
文件的情況下輕松重現這一點。
我在其他地方看到過這個抱怨,但大多數建議是你需要在 arm32v7 主機上構建一個 arm32v7 容器。 這是相當不切實際的。
我在 Ubuntu 19.04 和 18.10 上成功添加了一些架構模擬:
sudo apt-get install -y qemu qemu-user-static qemu-user binfmt-support
添加這些包后,錯誤消失,我可以創建我的 arm32v7 容器。
但是,這並不為Ubuntu 18.04或16.04的工作。
是否有適用於任何地方的通用解決方案?
似乎有一些安裝后步驟在 Ubuntu 18.04 和 16.04 上失敗了。
以下是解決 18.04 和 16.04 問題的幾種變通方法。
方法一:
git clone https://github.com/computermouth/qemu-static-conf.git
sudo mkdir -p /lib/binfmt.d
sudo cp qemu-static-conf/*.conf /lib/binfmt.d
sudo systemctl restart systemd-binfmt.service
方法二:
sudo mkdir -p /lib/binfmt.d
sudo sh -c 'echo :qemu-arm:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xfe\\xff\\xff\\xff:/usr/bin/qemu-arm-static:F > /lib/binfmt.d/qemu-arm-static.conf'
sudo sh -c 'echo :qemu-aarch64:M::\\x7fELF\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xfe\\xff\\xff\\xff:/usr/bin/qemu-aarch64-static:F > /lib/binfmt.d/qemu-aarch64-static.conf'
sudo systemctl restart systemd-binfmt.service
這有效,但超出了必要的層次。 我在 U18.04 上用 QEMU 做了很多,只需要做一次,因為最近的內核包含binfmt_misc
模塊(沒有服務層)。
請注意,我最近構建了自己的 QEMU,因為 Debian/Ubuntu 發行版有一個非常舊的版本(我記得是 2.x)。維護者遺漏的一個關鍵是--fix-binary yes
字段。
為 aarch64 安裝魔法 ELF 映射:
QEMU_AARCH64_EXEC=/opt/distros/qemu-5.1.0/bin/debug/native/aarch64-linux-user/qemu-aarch64
sudo update-binfmts \
--package qemu-user-static \
--install qemu-aarch64 $QEMU_AARCH64_EXEC \
--magic '\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00' \
--mask '\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' \
--offset 0 \
--credential yes \
--fix-binary yes
update-binfmts --display | grep 'qemu-aarch64 ' -A 7
要刪除映射:
sudo update-binfmts --package qemu-user-static --remove qemu-aarch64 $QEMU_AARCH_EXEC
update-binfmts --display
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.