The following is a quick guide to create systemd-nspawn container, which is a super-powered chroot on Arch Linux. There are a ton of ways to pull down or create container images, as well as options to launch and control containers. The following is only a sample of what I use to quickly get started.
Build the container image Link to heading
There are a number of tools or ways to create images. I use debootstrap:
|
|
This will demonstrate with an Ubuntu image. I need to pull down the base packages from an Ubuntu archive mirror:
|
|
This creates a Ubuntu Focal container in a folder called ‘ubuntu-focal’ using the specified mirror. Users can add and customize the container with any of the other debootsrap parameters as well.
Customize the image Link to heading
Users can also copy any files directly into the directory structure at this point.
While optional, it is nice to set a password before booting the full system:
|
|
Start the container Link to heading
Finall, boot the container, using the -b
flag to invoke init and complete a
full boot pointing to the directory of the container we created:
|
|
machinectl Link to heading
The machinectl
command is useful to out what containers are running as well
as to manage other containers:
|
|