qemu 跨架构

跨架构:在不同架构机器上运行其他架构容器

使用qemu静态文件启动目标架构dockers。

注意:目标架构是哪个,就下载哪个文件

下载:https://github.com/multiarch/qemu-user-static/releases/tag/v7.2.0-1

https://blog.csdn.net/m0_53195006/article/details/129890780

https://blog.csdn.net/happyblreay/article/details/139743957

x86_64平台通过qemu-user-static 运行arm64的docker镜像:

1、下载目标架构的qemu

下载路径:link

https://github.com/multiarch/qemu-user-static/releases

bash 复制代码
wget https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-aarch64-static.tar.gz
#下载后需要解压
tar -xzf xxx.tar.gz

2、初始化binfmt

bash 复制代码
#初始化和重置binfmt
docker run --rm --privileged multiarch/qemu-user-static --reset 
#设置binfmt(可能会失败,原因未知,解决方式是手动mount qemu-aarch64-static到容器;)
docker run --rm --privileged multiarch/qemu-user-static -p yes

qemu-user-static结合binfmt_misc来实现arm架构的指令模拟(文末有详细介绍)

可以通过检查 /proc/sys/fs/binfmt_misc 下的内容来确认是否成功启用。

bash 复制代码
root@testhost1:/root>ls -al /proc/sys/fs/binfmt_misc
total 0
drwxr-xr-x 2 root root 0 May 21 15:11 .
dr-xr-xr-x 1 root root 0 May 21 23:11 ..
-rw-r--r-- 1 root root 0 Jun 17 14:58 qemu-aarch64

在安装并配置好 qemu-user-static 与 binfmt_misc 后,你就可以直接使用 Docker 运行 ARM64 的镜像了。这时,Docker 与 QEMU 联动,能够在你的 x86_64 机器上模拟 ARM64 架构。

3、拉取arm版本的镜像

bash 复制代码
docker pull arm64v8/ubuntu:20.04

4、运行arm容器

需要把qemu-aarch64-static映射到目标容器里

需要指定目标容器的platform

bash 复制代码
docker run -it --rm --platform linux/arm64 -v $(pwd)/qemu-aarch64-static:/usr/bin/qemu-aarch64-static arm64v8/ubuntu:20.04  uname -m
bash 复制代码
#ok
docker run --cpus 48 --shm-size 32G --gpus all --memory 500gb --privileged=true -v /nfs2:/nfs2 -p 8065:8888 -it --platform linux/arm64 -v $(pwd)/qemu-aarch64-static:/usr/bin/qemu-aarch64-static --name czc_arch_pytest python:3.10.14-bookworm /bin/bash

docker run --cpus 48 --shm-size 32G --gpus all --memory 500gb -it  \
  --privileged=true -v /nfs2:/nfs2 -p 8065:8888  \
  --platform linux/arm64 -v $(pwd)/qemu-aarch64-static:/usr/bin/qemu-aarch64-static \
  --name czc_arch_pytest python:3.10.14-bookworm /bin/bash

问题:网络一直限速,不知道是不是容器问题,更新下

apt update && apt upgrade

相关推荐
Loo国昌7 小时前
Vue 3 前端工程化:架构、核心原理与生产实践
前端·vue.js·架构
tap.AI8 小时前
RAG系列(一) 架构基础与原理
人工智能·架构
The Open Group8 小时前
架构:不仅仅是建模,而是一种思维
架构
Solar20259 小时前
TOB企业智能获客新范式:基于数据驱动与AI的销售线索挖掘与孵化架构实践
人工智能·架构
brzhang11 小时前
A2UI:但 Google 把它写成协议后,模型和交互的最后一公里被彻底补全
前端·后端·架构
GIOTTO情11 小时前
多模态媒体发布技术架构解析:Infoseek 如何支撑科技舆情的极速响应?
科技·架构·媒体
山沐与山11 小时前
【Redis】Redis集群模式架构详解
java·redis·架构
AutoMQ12 小时前
How does AutoMQ implement a sub-10ms latency Diskless Kafka?
后端·架构
山沐与山12 小时前
【数据库】PostgreSQL架构与索引深度剖析
数据库·postgresql·架构
TimeFine14 小时前
Android AI解放生产力(六)实战:解放页面开发前的繁琐工作
android·架构