NixOS container limitations


#1

I saw the note in NixOS manual (https://nixos.org/nixos/manual/index.html#ch-containers):

Warning: Currently, NixOS containers are not perfectly isolated from the host system. This means that a user with root access to the container can do things that affect the host. So you should not give container root access to untrusted users.

Is there any detail why there’s that limitation and if currently someone is working on that.


#2

The reason for this is that it uses systemd-nspawn and at the time the implementation was written there was no support for user namespaces. Nowadays however we could add support for that…


#3

Nowadays however we could add support for that…

I guess that would be a great feature and would eliminate some use cases where docker or lxc or lxd is used today.


#4

Just found a PR that does exactly that:

Until it is merged (once the issues are resolved), you could add -U to extraFlags on a per-case basis.


#5

Thanks for clearification!