pyinfra icon indicating copy to clipboard operation
pyinfra copied to clipboard

Add a connector for systemd-nspawn (systemd container)

Open raphj opened this issue 5 months ago • 1 comments

systemd-nspawn offers lightweight containers. Chroot, but better, with optional network isolation, and features to automatically manage privileges, bind mounts.

Containers are long-lived, stored in a raw folder, usually in /var/lib/machines, and they can be booted using the systemd-nspawn command or using systemd services (and can be booted at startup). machinectl can then manage the containers. A container is identified with a name, and machinectl can also operate on a remote host.

machinectl shell can be used to run shell commands. machinectl also has copy-from and copy-to, so while copying from/to the directory directly works, there is a convenient wrapper for file transfers like what docker provides. There's also machinectl bind to add bind mounts.

Being able to set up a nspawn container using pyinfra would seem quite fitting :-)

raphj avatar Jul 14 '25 15:07 raphj

@Fizzadar has stated that he won't accept more connectors into the core pyinfra project, but connectors can be maintained as external projects.

xvello avatar Jul 23 '25 10:07 xvello