QA
Senior LevelLinux Commands & SysAdmin

What is systemd-nspawn and how does it launch lightweight OS container namespaces?

❓ Interview Prompt: Explain systemd-nspawn, namespace container isolation, booting full systemd init inside containers, and local testing.

'systemd-nspawn' is a container tool built directly into systemd that launches namespace-isolated process trees from root directory trees:

Advantages over Docker:

•
Boots a full, real systemd init process inside the container namespace.
•
Ideal for testing complete OS distributions, building packages, and testing systemd service units without running heavy VMs.

Code Implementation Example

bash
# Bootstrap minimal Debian rootfs using debootstrap
sudo debootstrap bookworm /var/lib/machines/debian-container

# Launch interactive systemd-nspawn container
sudo systemd-nspawn -D /var/lib/machines/debian-container --boot
💡Booting lightweight OS containers using systemd-nspawn.
🎯 Interview Key Takeaway

Use systemd-nspawn to launch lightweight OS containers with full systemd init trees for local testing.

#systemd-nspawn#Containers#Namespaces#Senior
Back to all Linux Commands & SysAdmin Questions→

More Linux Commands & SysAdmin Interview Questions

Beginner LevelLinux Commands & SysAdmin

How do Linux File Permissions (chmod, chown, chgrp) work in Octal and Symbolic notation?

Beginner LevelLinux Commands & SysAdmin

What is the Linux Filesystem Hierarchy Standard (/bin, /etc, /var, /usr, /opt, /tmp)?

Beginner LevelLinux Commands & SysAdmin

What are File Descriptors (0=stdin, 1=stdout, 2=stderr) and Redirection (>, >>, 2>&1)?