I needed a small container for experiments to run on my systemd-based machine. However, LXC and LXD were out of the question. Luckily, systemd has systemd-nspawn tool, which I used to build a container.

The size of the resulting rootfs is around 8.7 MB

Variables to tweak in the script:

  • MIRROR: the mirror to download packages from. The full list is available here.
  • VERSION: the version of Alpine to install. The full list is available here (as the list of directories)
  • if you are neither on x86 nor x86_64, you may need to adjust this line: [ "$(uname -m)" = "x86_64" ] && guestarch="x86_64" || guestarch="x86"

A Simple Script to Create systemd-nspawn Alpine Container
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *