LXD: Create X11 container

CONTAINER=x11
 
lxc remote add --protocol simplestreams ubuntu-minimal https://cloud-images.ubuntu.com/minimal/releases/
 
lxc launch ubuntu-minimal:22.04 ${CONTAINER}
 
lxc exec ${CONTAINER} -- sudo --login --user ubuntu
sudo apt update
sudo apt install -y x11-apps mesa-utils
exit
 
lxc config set ${CONTAINER} raw.idmap "both $UID 1000"
 
lxc restart ${CONTAINER}
 
lxc config device add ${CONTAINER} X0 disk path=/tmp/.X11-unix/X0 source=/tmp/.X11-unix/X0
lxc config device add ${CONTAINER} Xauthority disk path=/home/ubuntu/.Xauthority source=${XAUTHORITY}

Links
https://blog.simos.info/running-x11-software-in-lxd-containers/
https://blog.simos.info/how-to-run-teamviewer-in-lxd/
https://blog.simos.info/how-to-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/