systemd-nspawn is presented as a lightweight, Linux namespace-based alternative to Docker, especially useful when full virtual machines are unavailable or too costly, when containers need direct access to host files or hardware such as GPUs, or when Docker is unsuitable. Its key difference is that it generally uses a writable filesystem directory as the container’s root, rather than Docker-style read-only images built from Dockerfiles. The guide frames it as “chroot on steroids” and walks through creating those root filesystems: debootstrap for Debian-family systems, dnf for Fedora, and a purpose-built installer for Alpine. It warns that the usual Alpine chroot installer can bind host directories or mount host devices in hazardous ways, making cleanup and ownership changes risky.
The examples create containers under /var/lib/machines and compare their sizes: Alpine takes about 16 MB, Debian 338 MB, and Fedora 507 MB, with Fedora’s package cache accounting for much of its footprint and Debian shrinking to 305 MB after removing extras. To start a container, the guide uses systemd-nspawn with its root directory and machine name specified, plus private user namespaces that map container IDs to an isolated host range. It explains how to retain that mapping for later access and notes that an initial command provides only a root shell, not a proper persistent deployment. The remaining setup guidance covers basic Debian adjustments and ways to access a running container, including host-side tools, passwords, or SSH, with networking needed for remote access.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.