machinectl command examples
machinectl – Control the systemd machine manager
Example 1. Download an Ubuntu image and open a shell in it
# machinectl pull-tar https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-root.tar.gz # systemd-nspawn -M trusty-server-cloudimg-amd64-root
This downloads and verifies the specified .tar image, and then uses systemd-nspawn(1) to open a shell in it.
Example 2. Download a Fedora image, set a root password in it, start it as service
# machinectl pull-raw --verify=no http://ftp.halifax.rwth-aachen.de/fedora/linux/releases/21/Cloud/Images/x86_64/Fedora-Cloud-Base-20141203-21.x86_64.raw.xz # systemd-nspawn -M Fedora-Cloud-Base-20141203-21 # passwd # exit # machinectl start Fedora-Cloud-Base-20141203-21 # machinectl login Fedora-Cloud-Base-20141203-21
This downloads the specified .raw image with verification disabled. Then a shell is opened in it and a root password is set. Afterwards the shell is left, and the machine started as system service. With the last command a login prompt into the container is requested.