63e40eab6f320e9e94d4d6a2050.../fookat.md

9.6 KiB

Which LXC images are good for VNC? I've had varying success with installing XFCE and RealVNC server on different LXC images, so I tested each one to figure out which ones I should use.

  • Host: Ubuntu 20.04.1 LTS on kernel Linux 5.4.0-52-generic
  • LXD version 4.7

Ubuntu 20.04

Setup procedure

lxc launch ubuntu:20.04 test
lxc exec test -- bash
apt update
apt install xfce4
wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.deb
apt install ./VNC-Server-6.7.2-Linux-x64.deb
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
su -l ubuntu
vncserver :1

Result

VNC session immediately exits. Here are the contents of the VNC log and .xsession-errors.

Enabling system Xorg did not help.

Debian 10

Setup procedure

lxc launch images:debian/10 test2
lxc exec test2 -- bash
apt update
apt install xfce4
apt install wget
wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.deb
apt install ./VNC-Server-6.7.2-Linux-x64.deb
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
vncserver :1
# this works, so let's finish set up
echo "ConnectToExisting=1" >> /etc/vnc/config.d/vncserver-virtuald
systemctl enable --now vncserver-virtuald
adduser foo

Result

VNC session works nicely.

However due to the old Xorg server built into Xvnc, you cannot change the resolution using the Display settings, so you have to add i.e. -geometry 1366x768 to your ~/.vnc/config. And for some reason, RealVNC does not recommend using the system Xorg server on Debian/Ubuntu systems.

But I did it anyway and it works.

image

Fedora 33

Setup procedure

lxc launch images:fedora/33 test3
lxc exec test3 -- bash
dnf groupinstall Xfce
dnf install https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.rpm
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
vncserver :1
dnf install xorg-x11-drv-dummy
vncinitconfig -enable-system-xorg
# Now it starts, but...

Result

Session immediately exits. [VNC log] [.xsession-errors]

CentOS 8

Setup procedure

lxc launch images:centos/8 test4
lxc exec test4 -- bash
dnf install epel-release
dnf groupinstall Xfce
dnf install https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.rpm
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
dnf install xorg-x11-drv-dummy
vncinitconfig -enable-system-xorg
vncserver :1

Result

This works, but for some reason the Xfce group on CentOS includes a minimal GNOME session, which the xstartup script will run instead of Xfce. So the xstartup script has to be customized to explicitly start Xfce.

So after adding the following to /etc/vnc/xstartup.custom and making it executable...

#!/bin/sh
DESKTOP_SESSION=xfce
export DESKTOP_SESSION
startxfce4
vncserver-virtual -kill $DISPLAY

The Xfce session works now. And the resolution can be changed in Display settings.

image

Conclusion

CentOS does not seem like a good choice for a virtual XFCE desktop, but it works well with GNOME. You can install the 'Server with GUI' group for the complete experience.

OpenSUSE 15.2

lxc launch images:opensuse/15.2 test5
lxc exec test5 -- bash
zypper install -t pattern xfce
zypper install https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.rpm
zypper install xauth
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
vncserver :1
# xstartup did not find XFCE, so I had to create a custom xstartup like I did for CentOS
vncserver -kill :1
zypper install nano
nano /etc/vnc/xstartup.custom # pasted the stuff
chmod a+x /etc/vnc/xstartup.custom
vncserver :1
passwd

And it works :)

However, like Debian, it uses Xvnc so changing resolution is a little tedious, and they do not recommend using system Xorg on SUSE.

But I tried it anyway (zypper install xf86-video-dummy; vncinitconfig -enable-system-xorg) and it works!

image

Fedora 32

lxc launch images:fedora/32 test6
lxc exec test6 -- bash
dnf groupinstall Xfce
dnf install https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.rpm
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
dnf install xorg-x11-drv-dummy
vncinitconfig -enable-system-xorg
vncserver :1

VNC server immediately exits. [VNC log] [.xsession-errors]

This is weird, because I had previously set up a Fedora 32 container with Xfce VNC just like this and it worked fine. But when I tried with Fedora 33, I had this problem, so this is why I tested Fedora 32 again.

Could it maybe be because I had installed the "Development Tools" group before installing Xfce?

I tried installing it here but still have the same issue. Weird.

Maybe it's because that container was on a CentOS 8 kernel (4.18.0-193.19.1.el8_2.x86_64), while this one is on Ubuntu kernel (5.4.0-52-generic)? 🤷

Ubuntu 18.04

lxc launch ubuntu:18.04 test7
lxc exec test7 -- bash
apt update
apt install xfce4
wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.deb
apt install ./VNC-Server-6.7.2-Linux-x64.deb
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
passwd ubuntu
su -l ubuntu
vncserver :1

It works!

And it also works with system Xorg! (apt install xserver-xorg-video-dummy; vncinitconfig -enable-system-xorg)

image

Ubuntu 16.04

lxc launch ubuntu:16.04 test8
lxc exec test8 -- bash
apt update
apt install xfce4
wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.deb
apt install ./VNC-Server-6.7.2-Linux-x64.deb
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
su -l ubuntu
vncserver :1

Xenial is nearing end of life soon, but I was curious. It also works fine :)

Linux Mint 19 (based on Ubuntu 18.04)

lxc launch images:mint/tricia test9
lxc exec test9 -- bash
apt install xfce4
apt install wget
wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.deb
apt install ./VNC-Server-6.7.2-Linux-x64.deb
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
su -l ubuntu
vncserver :1

Huh, this does not work. [VNC log] [.xsession-errors]

Not testing Mint 20 as I'm pretty sure it won't work. Thought this might as it's based on 18.04.

Fedora 33, but with GNOME

lxc launch images:fedora/33 test10
lxc exec test10 -- bash
dnf groupinstall GNOME
dnf install https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.2-Linux-x64.rpm
vnclicense -add 4R22B-2BA48-RZH9Y-MLAAF-HCYNA
dnf install xorg-x11-drv-dummy
vncinitconfig -enable-system-xorg
vncserver :1

It works! https://o1tc.qonq.gq

image

Conclusion

Preferably, you want to use the system Xorg so you can change display resolution and run some newer software that requires it. But RealVNC only recommends (and in my experience, requires) using it on RedHat-based distros, not on other distros for some reason. But you can try it anyway and it seems to work fine, so I don't know why they advise against it.

So if you want to follow their recommendation, that leaves you with just CentOS or Fedora, which haven't given me the greatest experience with setting up Xfce VNC, the latter not even working at all, which is weird, because it worked nicely on my other system, so I can only guess it's because of the different kernels. (same LXD version btw)

However, both of these distros work great if you want GNOME. It's a nice desktop environment but relatively resource intensive so I don't recommend it for small or underpowered systems. For those, you want to use XFCE. But if you have a fairly beefy host then CentOS with GNOME might be the ideal VNC platform. Or you can install the "Server with GUI" package group for even more goodies.

But since system Xorg seems to work fine on other distros, Debian 10 and Ubuntu 18.04 look like the ideal choices. I could never get Xfce VNC to work in 20.04 containers and could never figure out why. But at least 18.04 works, which is pretty similar to 20.04 and still has a few years of support left. Ubuntu has more stuff pre-installed, including snapd (with lxd pre-installed) and SSH server (with password authentication disabled tho), and a pre-made ubuntu user you can use right away. While Debian is slimmer but may need a little more set up.

openSUSE 15.2 is also a fairly nice option; you just need to add the custom xstartup config, but it has a nice openSUSE-themed pre-configured Xfce desktop with whisker menu and task bar on the bottom.

Note that this isn't a tutorial, but if you're installing VNC, you should create a user (don't use root), enable and use vncserver-virtuald, and uninstall any screensavers. You don't want xscreensaver wasting cpu on drawing a nice animation that nobody sees.