我的服务器和docker信息。如下所示:
Linux xxx 3.10.0-1160.66.1.el7.x86_64 #1 xxx x86_64 x86_64 x86_64 GNU/Linux
Docker version 20.10.17
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Server Version: 20.10.17
Kernel Version: 3.10.0-1160.66.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
我想通过QEMU构建一个docker容器。我遵循了QEMU官方github的指示。但它给出了错误。
$ uname -m
x86_64
$ docker run --rm -t arm64v8/ubuntu uname -m
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
exec /usr/bin/uname: exec format error
然后我在stackoverflow上发现了一个类似的docker问题。我尝试了docker build
和docker buildx
,但仍然不起作用。
$ docker build --platform linux/arm64/v8 .
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /work/home/chenning/Dockerfile: no such file or directory
$ docker buildx build --push --platform linux/amd64,linux/arm64 -t <tag> .
-bash: tag: No such file or directory
我也尝试了以下指令,但它仍然报告了错误。
$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
sh: write error: Invalid argument
Setting /usr/bin/qemu-alpha-static as binfmt interpreter for alpha
Setting /usr/bin/qemu-arm-static as binfmt interpreter for arm
sh: write error: Invalid argument
Setting /usr/bin/qemu-armeb-static as binfmt interpreter for armeb
sh: write error: Invalid argument
Setting /usr/bin/qemu-sparc-static as binfmt interpreter for sparc
sh: write error: Invalid argument
...
我遵循了这个链接的指南
当我尝试时它有效
docker run --rm --privileged multiarch/qemu-user-static:register
我在/proc/sys/fs/binfmt_misc
中有qemu解释器(包括qemu-aarch64
(
我的qemu-aarch64
就像这个
enabled
interpreter /usr/bin/qemu-aarch64-static
flags:
offset 0
magic 7f454c460201010000000000000000000200b700
mask ffffffffffffff00fffffffffffffffffeffffff
但我没有更改flags
的权限,我也没有interpreter /usr/bin/qemu-aarch64-static
。
我能得到一些帮助吗?
我得到了同样的错误,但执行此命令修复了问题:
$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
所以我甚至可以生成一个外壳:
$ docker run -it arm64v8/ubuntu /bin/bash
root@0b6162g03ka5:/# uname -m
aarch64
如果它不起作用,看看这个问题,否则你应该在github 上创建一个新问题
忽略这将使您免于痛苦。
对我来说,安装qemu
就足够了
sudo apt install qemu-user qemu-user-static gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu binutils-aarch64-linux-gnu-dbg build-essential