LXD container

Create default container

CONTAINER_NAME=www1-dev
 
lxc launch ubuntu:20.04 ${CONTAINER_NAME} -c boot.autostart=true -p disk-zfs -p nic-dev-mgmt
# -c security.privileged=true
 
# lxc exec ${CONTAINER_NAME} -- rm /etc/netplan/50-cloud-init.yaml
# lxc exec ${CONTAINER_NAME} -- bash -c "cat <<EOF> /etc/netplan/dev-mgmt.yaml
# network:
#   version: 2
#   ethernets:
#     dev-mgmt:
#       dhcp4: no
#       addresses: [10.33.0.131/24]
#       gateway4: 10.33.0.1
#       routes:
#         - to: 10.33.0.0/16
#           via: 10.33.0.1
#       nameservers:
#         addresses: [10.0.0.111, 10.0.2.222]
#         search: [dev.example.com]
# EOF
# "
 
lxc file push /root/.ssh/authorized_keys ${CONTAINER_NAME}/root/.ssh/authorized_keys
 
lxc exec ${CONTAINER_NAME} -- apt update
lxc exec ${CONTAINER_NAME} -- apt dist-upgrade -y
lxc exec ${CONTAINER_NAME} -- apt purge -y lxd lxd-client unattended-upgrades packagekit linux-image-unsigned-5.6.0-1026-oem
lxc exec ${CONTAINER_NAME} -- systemctl disable snapd.service && umount  /snap && apt purge -y snapd
lxc exec ${CONTAINER_NAME} -- apt autoremove -y
lxc exec ${CONTAINER_NAME} -- apt clean
 
lxc exec ${CONTAINER_NAME} -- locale-gen en_US.UTF-8