News for hackers. Stuff that matters.
Re:Running Systemd-Nspawn Containers by letters90 on Friday February 21, 2025 @04:14AM (#43125596)
I used nspawn to get a system running in the most ridiculous way.

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.

Re:Running Systemd-Nspawn Containers by Imustaskforhelp on Friday February 21, 2025 @04:31AM (#43125694)
hmm this is very interesting.

I am wondering though? Is there something like systemd-nspawn that doesn't require root?

Re:Running Systemd-Nspawn Containers by vlowrian on Friday February 21, 2025 @06:56AM (#43126520)
If file system level isolation is enough for you, take a loot at schroot (https://linux.die.net/man/1/schroot) which allows root-less chroot. You can use something like debootstrap to get a complete userland into a user controlled directory and use schroot to chroot into it without root level access.
Re:Running Systemd-Nspawn Containers by Imustaskforhelp on Friday February 21, 2025 @09:18AM (#43127702)
this is crazy , trying this out right now.

But is there a way to also run OCI compatible directly on this as well?

Re:Running Systemd-Nspawn Containers by mst on Friday February 21, 2025 @09:22AM (#43127753)
You could use docker export to sluro the container contents (see article for example)
Re:Running Systemd-Nspawn Containers by Imustaskforhelp on Friday February 21, 2025 @09:21AM (#43127744)
EDIT: it seems that for creating a chroot you still require root.

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

Re:Running Systemd-Nspawn Containers by igor47 on Friday February 21, 2025 @11:38AM (#43129598)
fakeroot has nothing to do with qemu -- it simply uses LD preload to make commands think they're uid 0
Re:Running Systemd-Nspawn Containers by ttyprintk on Friday February 21, 2025 @09:38AM (#43127914)
Fakeroot is good for the debootstrap step, and then schroot runs unprivileged.
Re:Running Systemd-Nspawn Containers by NekkoDroid on Friday February 21, 2025 @06:37PM (#43134467)
> it seems that for creating a chroot you still require root.

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>`.
Re:Running Systemd-Nspawn Containers by derobert on Friday February 21, 2025 @04:44AM (#43125752)
It looks like systemd-nspawn is gaining rootless support, see https://github.com/systemd/systemd/issues/30239

Until then, I'm not sure if there is anything lightweight. If you don't need lightweight, there is Podman.

Re:Running Systemd-Nspawn Containers by Imustaskforhelp on Friday February 21, 2025 @05:14AM (#43125920)
Podman requires one time root for installation though.

I am on a completely rootless client at one of my servers.

Re:Running Systemd-Nspawn Containers by tobwen on Saturday February 22, 2025 @10:43AM (#43139963)
Nope, you can compile/download and run it completely from unprivileged userspace.
Re:Running Systemd-Nspawn Containers by NekkoDroid on Friday February 21, 2025 @06:59PM (#43134643)
Do note that the current support is limited to signed disk images, while it was recently (still not in a release) gained the ability to use any directory that resides inside a signed disk image (instead of just the entire disk image).
Re:Running Systemd-Nspawn Containers by 1oooqooq on Friday February 21, 2025 @05:10AM (#43125889)
all containers require root.

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.

Re:Running Systemd-Nspawn Containers by Imustaskforhelp on Friday February 21, 2025 @05:15AM (#43125928)
you can theoretically run a virtual machine like libriscv5 which doesn't require root. or qemu doesn't require root as well. But qemu is blocked for my usecase. There is flatpak theoretically as well

There is podman but it requires one time root.

Re:Running Systemd-Nspawn Containers by 1oooqooq on Friday February 21, 2025 @06:45PM (#43134536)
qemu is great but it's a VM, not a container.
Re:Running Systemd-Nspawn Containers by yjftsjthsd-h on Friday February 21, 2025 @09:38AM (#43127918)
Linux user namespaces can be used to create containers without having root access, see ex. https://unix.stackexchange.com/questions/66084/simulate-chro...

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

Re:Running Systemd-Nspawn Containers by 1oooqooq on Friday February 21, 2025 @06:45PM (#43134532)
you can't detach your username from a process, nor the network ns... etc, etc, etc.

yeah you can do some smaller fakechroot and maybe some bind mounts... if you call that a "container" good for you.

Re:Running Systemd-Nspawn Containers by yjftsjthsd-h on Sunday February 23, 2025 @08:38PM (#43155031)
> you can't detach your username from a process, nor the network ns... etc, etc, etc.

Sure looks like it works?

  $ unshare -i -n -p -u -T -r -f
  # ls
  # id
  gid=0(root) groups=0(root),65534(nogroup)
  # ip -br a
  lo               DOWN
> yeah you can do some smaller fakechroot and maybe some bind mounts... if you call that a "container" good for you.

Why are you being condescending about what constitutes a container?

Re:Running Systemd-Nspawn Containers by i_v on Friday February 21, 2025 @04:36AM (#43125717)
I used to use qemu-user-static to run ARM Linux distros like Buildroot, Yocto, and Raspbian on x88_64. It worked surprisingly well! Outside of some minor bugs here and there, it was perfect for local development, emulating an embedded system I was working on.
Re:Running Systemd-Nspawn Containers by vaylian on Friday February 21, 2025 @04:55AM (#43125809)
You might want to look into .nspawn files instead. Then you can also manage your nspawn-containers with the machinectl command.

See 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.

Re:Running Systemd-Nspawn Containers by Vilian on Friday February 21, 2025 @08:50PM (#43135297)
Why run the Debian VM? Just use nspawn directly