岑韬哎 发表于 2025-6-7 09:37:15

使用ruri快速构建跨架构chroot容器

在开发过程中,我们偶尔会用到跨架构Linux容器。
ruri全称“轻量型,用户友好的Linux容器实现”,是一个1M左右大小的Linux容器实现,提供了一系列功能选项,致力于成为更加强大且安全的chroot命令替换。
我们以在x86_64系统下运行arm64的Ubuntu容器为例:
确认binfmt_misc支持:

~$ cat /proc/filesystems | grep binfmt_misc
nodev   binfmt_misc确保能看见binfmt_misc的输出,大多系统甚至安卓的GKI内核应该都是支持的。
安装qemu-user-static:

sudo apt install qemu-user-static获取rootfs:

这里使用作者编写的rootfstool脚本:
git clone https://github.com/Moe-hacker/rootfstool
cd rootfstool
./rootfstool download --mirror bfsu --distro ubuntu --version noble --arch arm64于是我们得到了rootfs.tar.xz
获取ruri二进制:

前往https://github.com/moe-hacker/ruri/releases,下载最新的ruri-x86_64
wget https://github.com/Moe-hacker/ruri/releases/download/v3.3/ruri-x86_64
chmod 777 ruri-x86_64解压rootfs,启动:

mkdir ubuntu-arm64
tar -xvf /path/to/rootfs.tar.xz -C ubuntu-arm64
cp /usr/bin/qemu-aarch64-static ubuntu-arm64/
sudo ./ruri-x86_64 -a aarch64 -q /qemu-aarch64-static ./ubuntu-arm64/配置容器DNS:

最后在容器中:
rm /etc/resolv.conf
echo nameserver 114.114.114.114 > /etc/resolv.conf
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

柯惠心 发表于 2025-11-4 03:22:01

感谢发布原创作品,程序园因你更精彩

叟减 发表于 2025-11-30 08:58:46

新版吗?好像是停更了吧。

这帜 发表于 2026-1-17 17:59:49

热心回复!

裒噎 发表于 2026-1-19 06:32:40

很好很强大我过来先占个楼 待编辑

稞冀 发表于 2026-1-20 12:54:32

过来提前占个楼

广性 发表于 2026-1-21 09:44:20

感谢,下载保存了

茹静曼 发表于 2026-1-22 12:02:41

鼓励转贴优秀软件安全工具和文档!

咚獭 发表于 2026-2-2 03:25:19

谢谢楼主提供!

煞赶峙 发表于 2026-2-4 06:31:56

前排留名,哈哈哈

顾星 发表于 2026-2-7 06:19:26

yyds。多谢分享

步雪卉 发表于 2026-2-8 12:11:07

谢谢楼主提供!

吮槌圯 发表于 2026-2-8 12:22:51

东西不错很实用谢谢分享

呈步 发表于 2026-2-8 23:23:25

收藏一下   不知道什么时候能用到

少琼 发表于 2026-2-9 05:03:56

谢谢分享,试用一下

凉砧掌 发表于 2026-2-10 16:51:17

前排留名,哈哈哈

村亢 发表于 2026-2-11 10:30:40

过来提前占个楼

司寇涵涵 发表于 2026-2-12 14:31:46

鼓励转贴优秀软件安全工具和文档!

侧胥咽 发表于 2026-2-13 21:02:29

新版吗?好像是停更了吧。

马璞玉 发表于 2026-2-21 04:07:59

分享、互助 让互联网精神温暖你我
页: [1] 2
查看完整版本: 使用ruri快速构建跨架构chroot容器