by letters90 · 1y ago · 0 comments
A debian aarch64 vm on kvm starting a systemd-nspawn for an unpacked raspberry pi 3 iso.
It works way too well judging by how ridiculous it was.
Still saved me a few days instead of setting things up myself.
I actually liked how easy it is to spin up nspawn as a systemd service
[Unit]
Description=Raspberry Image Machine
After=multi-user.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/systemd-nspawn -D /mnt/ /sbin/init
[Install]
WantedBy=multi-user.targetSee man 5 systemd.nspawn
And many command like systemctl and journalctl accept the -M parameter, which allows you to query systemd units inside your nspawn-containers from the host.
edit: The article actually explains all of these things in more detail.
I am wondering though? Is there something like systemd-nspawn that doesn't require root?
But is there a way to also run OCI compatible directly on this as well?
I don't have root on that system and so I can't create a chroot , there is fakeroot but it doesn't work since it uses qemu on that locked system.
Are there any other alternatives
You actually don't as long as you have user namespaces.
One thing I am working on I use chroot (rather unshare --root=) to minimally sandbox a subprocess. At the beginning of the script I have this little snippet:
if [ "$(id --user)" -ne 0 ]; then
exec unshare --map-root-user --mount -- "$0" "$@"
fi
Though you can probably just do something roughtly as `unshare --map-root-user --root=<PATH>`.Until then, I'm not sure if there is anything lightweight. If you don't need lightweight, there is Podman.
I am on a completely rootless client at one of my servers.
docker and the rootless nonsense is just root daemons and suid.
...would never have believed marketing lies would reach linux tools if anyone told me this before 2018.
There's also https://github.com/termux/proot-distro which may or may not count as containers depending on how you define the word but I think it does count
yeah you can do some smaller fakechroot and maybe some bind mounts... if you call that a "container" good for you.
There is podman but it requires one time root.