Systemd/Nspawn

From Bibliotheca Anonoma
Revision as of 20:40, 30 January 2018 by Antonizoon (talk | contribs) (→‎nSpawn)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Sometimes I need to do development using a Debian-based system, but I usually use Arch or Fedora.

Thus, I set up a chroot to run such systems with no performance loss. Heck, I even throw in systemd-nspawn to spice things up.

Installation

Fedora

su -c 'dnf install debootstrap dpkg'

http://blog.parahard.com/2013/03/creating-debian-chroot-inside-fedora.html

Usage

You can set up multiple types of distros under the chroot.

Debian

debootstrap --arch=amd64 unstable debian-tree/

http://blog.exppad.com/article/a-docker-like-container-management-using-systemd

Management

Systemd provides some helpful utilities to manage containers:

machinectl

https://wiki.archlinux.org/index.php/Systemd-nspawn#machinectl

nSpawn

https://gist.github.com/aputs/0476fd313a86c66a6927

   #!/bin/bash
   # boot the container as given in first argument
   sudo systemd-nspawn -d "$1" --boot

Docker

https://www.digitalocean.com/community/tutorials/docker-explained-how-to-create-docker-containers-running-memcached

https://docs.docker.com/engine/userguide/dockerimages/

Docker does all of this for you.