tfc / nspawn-nixos

Accompanying Code for Nixcademy.com Blog Article
https://nixcademy.com/2023/08/29/nixos-nspawn/
41 stars 6 forks source link

Add description how to enable cgroups v2 inside a container. #4

Open carbolymer opened 6 months ago

carbolymer commented 6 months ago

After starting the container, systemd uses cgroups v1 by default for nixos guest. This is a problem for example when running podman inside a container which reports that cgroups are in hybrid mode and does not allow to do anything.

To fix this and avoid the issue, one has to set SYSTEMD_NSPAWN_UNIFIED_HIERARCHY=1 in a service override on the host machine using systemctl edit systemd-nspawn@nixos (replace nixos with your container name):

[Service]
Environment="SYSTEMD_NSPAWN_UNIFIED_HIERARCHY=1"

I'm not sure where to put this information, probably README.md would be the best.

tfc commented 6 months ago

Thank you for bringing this up! Documenting this seems like a very good idea.

Putting this into README.md seems appropriate. Are you interested in creating a PR that extends the readme with some "Further Configuration" section or similar?