LXD

Log

To run lxd init start lxd first:

systemctl start lxd.service
systemctl status lxd.service

Then run lxd init and configure to use ZFS. Use existing pool if have one or create new. Existing pool will have no mounting point:

zfs list

Add user to lxd group to manage lxd using that user.

List all LXD images

image list website.

lxc image list images:
lxc image list ubuntu:18.04 arch=amd64

To create container from image with random name:

lxc launch ubuntu:18.04   (failed!)
lxc launch ubuntu:2cfc5a5567b8   (Ubuntu 18.04 LTS container)  (failed!)
lxc launch ubuntu:9e90b7b9ccdd   (Ubuntu 18.04 LTS VM)  (failed!)

The following creates a copy from built-in repository ‘images’ with container name as last argument:

lxc launch images:centos/7/amd64 centos    (worked)
lxc launch images:ubuntu/18.04/amd64 ubuntu    (worked)

To create container and give it a name:

lxc launch images:debian/9 wordpress-site

To list containers:

lxc list

To get shell:

lxc exec $container_name /bin/bash

Create lxc user and lxc group

groupadd -g 65536 lxc
useradd -u 65536 -g 65536 -M -s /usr/bin/nologin lxc

References

  1. Official LXC Documentation
  2. Linux Containers at Arch Wiki
  3. LXD at Arch Wiki from archlinux.
  4. Install Ubuntu 18.04 on lxd