{
  "id": 16219188,
  "title": "A whirlwind tour of systemd-nspawn containers (2025)",
  "url": "https://urgent.news/2026/10/23/a-whirlwind-tour-of-systemd-nspawn-containers-2025",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-23T17:12:35.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://quantum5.ca/2025/03/22/whirlwind-tour-of-systemd-nspawn-containers/"
  },
  "original_language": "en",
  "account": "In the most recent yearly update, the author discussed isolating self-hosted Large Language Models (LLMs) running in Ollama and Open WebUI using systemd-nspawn containers. However, the process of setting up and using these containers turned into a separate blog post. Systemd-nspawn is a lightweight Linux namespaces-based container technology similar to Docker, differing primarily in image management. Instead of building images with Dockerfiles and distributing prebuilt images, systemd-nspawn uses a writable root filesystem, functioning more like a virtual machine. The author finds it especially useful in scenarios such as running software on different Linux distributions or creating lightweight containers.\n\nTo set up a systemd-nspawn container, you need a separate root filesystem (rootfs) in a directory. Typically, these rootfses are stored under /var/lib/machines/[hostname], where the hostname is the container name. For this example, the author uses the name of the OS as the hostname. Each Linux distribution has its own method of creating a new rootfs, which will be explained for common distributions like Debian, Fedora, and Alpine Linux.\n\nFor Debian-based distributions, the tool debootstrap is used to create a rootfs. After installing debootstrap, the rootfs can be created with commands such as sudo debootstrap --arch=amd64 bookworm /var/lib/machines/debian http://deb.debian.org/debian. Additional packages like systemd, dbus, locales, bash-completion, and curl can be installed for a more comfortable environment. The author then describes creating containers for Fedora 41 and Alpine Linux using the alpine-nspawn-install script, which installs a more reasonable set of packages compared to the default alpine-chroot-install.\n\nOnce the rootfs is ready, systemd-nspawn can be installed with sudo apt install systemd-container or the equivalent command for the user's distro. To access the container, use the command systemd-nspawn -b -D /var/lib/machines/[hostname]. This command provides a root shell in the newly created container. While this is not a proper way to deploy the container long-term, it can be used to run applications or interact with the container.\n\nFor a more permanent solution, the author suggests setting up the container to run in the background using systemd. This allows for better management, including configuring an init process, setting up users, and customizing the environment.",
  "summary": null,
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}