我可以设置一个ARM64 Docker映像,但是可以运行任何东西
我有一个centos 7 x86_64虚拟机。我需要在Oracle Linux 8 ARM64 Docker容器中做一些事情。
我安装了Docker和Qemu:
$ sudo yum install -y yum-utils
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin \
qemu-system-arm qemu qemu-user qemu-kvm qemu-kvm-tools libvirt virt-install \
libvirt-python libguestfs-tools-c
然后,我启动Docker并设置QEMU-USER静态:
$ sudo systemctl start docker
$ docker run --rm --privileged multiarch/qemu-user-static --reset
我的DockerFile是:
FROM oraclelinux:8.5
ENV container docker
RUN dnf -y install sssd nscd unzip zip xz which file
RUN useradd --uid 1001 -ms /bin/bash cm
RUN uname -m
然后使用以下内容创建X86_64和ARM64映像:
docker buildx create --name ol8_builder
docker buildx --builder ol8_builder build -t frickson/oracle8 . --platform=linux/amd64 --load --progress=plain
docker buildx --builder ol8_builder build -t frickson/oracle8arm . --platform=linux/arm64 --load --progress=plain
在两个图像上的构建过程中,run uneradd
工作和用户是创建的。 运行UNAME -M
在两个系统上都可以使用,生成正确的输出(x86_64
和aarch64
)。
X86_64机器工作正常:
$ docker run --rm --privileged frickson/oracle8 uname -m
x86_64
但是ARM64机器没有:
$ docker run --platform linux/arm64 --rm --privileged frickson/oracle8arm uname -a
exec /usr/bin/uname: no such file or directory
我猜它没有找到一个或多个库,因为它在图像构建过程中起作用。尝试运行任何命令(bash
,ls
,true
)都会在同一错误消息中导致。
有什么想法我缺少什么?谢谢!
编辑:回答 @josephsible-reinstatemonica:
它不起作用。而且我无法访问手臂主机来检查我的图像。
$ sudo docker run --platform linux/arm64 -it --rm --privileged oraclelinux:8 /bin/bash
Unable to find image 'oraclelinux:8' locally
8: Pulling from library/oraclelinux
e12ce518ed4b: Pull complete
Digest: sha256:cad3a3dc2dd9f03dec02642dce1f194562e7f21820bc36ceb9f7b070d337fb45
Status: Downloaded newer image for oraclelinux:8
exec /bin/bash: no such file or directory
I have a CentOS 7 x86_64 virtual machine. I need to do some things in an Oracle Linux 8 arm64 docker container.
I installed docker and qemu:
$ sudo yum install -y yum-utils
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin \
qemu-system-arm qemu qemu-user qemu-kvm qemu-kvm-tools libvirt virt-install \
libvirt-python libguestfs-tools-c
I then started docker and set up qemu-user-static:
$ sudo systemctl start docker
$ docker run --rm --privileged multiarch/qemu-user-static --reset
My Dockerfile is:
FROM oraclelinux:8.5
ENV container docker
RUN dnf -y install sssd nscd unzip zip xz which file
RUN useradd --uid 1001 -ms /bin/bash cm
RUN uname -m
Then created x86_64 and arm64 images using the following:
docker buildx create --name ol8_builder
docker buildx --builder ol8_builder build -t frickson/oracle8 . --platform=linux/amd64 --load --progress=plain
docker buildx --builder ol8_builder build -t frickson/oracle8arm . --platform=linux/arm64 --load --progress=plain
During the build on both images, the RUN useradd
works and the user is created. The RUN uname -m
works on both systems, producing the correct output (x86_64
and aarch64
respectively).
The x86_64 machine works correctly:
$ docker run --rm --privileged frickson/oracle8 uname -m
x86_64
But the arm64 machine does not:
$ docker run --platform linux/arm64 --rm --privileged frickson/oracle8arm uname -a
exec /usr/bin/uname: no such file or directory
I'm guessing it's not finding one or more libraries, since it worked during the image build. Trying to run any command (bash
, ls
, true
) all result in the same error message.
Any ideas what I'm missing? Thanks!
EDIT: In response to @JosephSible-ReinstateMonica:
It didn't work. And I don't have access to an ARM host to check my image.
$ sudo docker run --platform linux/arm64 -it --rm --privileged oraclelinux:8 /bin/bash
Unable to find image 'oraclelinux:8' locally
8: Pulling from library/oraclelinux
e12ce518ed4b: Pull complete
Digest: sha256:cad3a3dc2dd9f03dec02642dce1f194562e7f21820bc36ceb9f7b070d337fb45
Status: Downloaded newer image for oraclelinux:8
exec /bin/bash: no such file or directory
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您运行
docker运行-RM-私有的Multiarch/Qemu-user static -Reset
时,它将Aarch64二进制文件的处理程序设置为:不幸的是,Centos 7没有
没有
- 静态
这些二进制文件的版本:幸运的是,
Multiarch/Qemu-user static
容器在图像中包含必要的二进制文件;您可以像这样复制到主机上:现在我们有:
这使我们如此接近,但是我们需要将静态二进制安装到图像中,如 for Multiarch/qemu-user static :(
或您需要将解释器构建到图像中。)
我们需要Mount
QEMU-AARCH64静态
在CentOS 7上的容器内部,因为内核似乎不支持f
flagBINFMT_MISC
解释器。f
标志意味着:(来自“ noreferrer”> kernel document
) Multiarch/Qemu-user static 如果您设置
- 在命令行上持续YES
,但是在CentOS 7上失败了:使用最近的Fedora发行版(以及可能还有其他),您可以简单地安装
QEMU-user static /code>软件包,一切都将工作(无需使用
Multiarch/Qemu-user static
image):qemu-user static
软件包软件包安装所有<代码> binfmt_misc给您的注册。
When you run
docker run --rm --privileged multiarch/qemu-user-static --reset
, it sets the handler for aarch64 binaries to:Unfortunately, CentOS 7 doesn't have the
-static
versions of these binaries:Fortunately, the
multiarch/qemu-user-static
container includes the necessary binaries in the image; you can copy onto your host like this:Now we have:
This gets us so close, but we need to mount the static binary into the image as described in the docs for multiarch/qemu-user-static:
(Or you need to build the interpreter into the image.)
We need to mount
qemu-aarch64-static
inside the container on CentOS 7 because the kernel doesn't appear to support theF
flag forbinfmt_misc
interpreters. TheF
flag means:(from the kernel documentation)
multiarch/qemu-user-static
will set theF
flag if you set--persistent yes
on the command line, but on CentOS 7 this fails with:With recent Fedora distributions (and probably others as well), you can simply install the
qemu-user-static
package and everything will Just Work (no need to use themultiarch/qemu-user-static
image):The
qemu-user-static
package installs all thebinfmt_misc
registrations for you.