Lxc launch ... --console=vga fails (gtk-warning cannot open display)

Hello, newbie here!

I didn’t know about LXD/LXC until two weeks ago, and now I’m liking it a lot! I’ve got a new NUC13, where I installed Ubuntu 22.04 server. My purpose is to keep its installation as clean as possible (minimizing any extra installations), and have all my needs running in VM’s and/or containers on top of it - with LXD. So far so good, I’ve even managed to install a windows 11 VM on top of it - very happy!

I started out with the plan to have this NUC run headless in some corner, with no need to login physically on the console. Those VM’s and containers which contain a desktop installation, I’ve made them headless, so I can login remotely with a remote desktop client. No ssh tunneling etc needed. Appears to work great.

Now I came to think that sometimes I’d like to login physically on the console, and after console login start a VM (or container) with a desktop, and be able to use that VM desktop directly.

With that in mind, I found this guide and tried it:

After command
lxc launch images:ubuntu/22.04/desktop ubuntu --vm -c limits.cpu=4 -c limits.memory=4GiB --console=vga

I get an error saying “…gtk-warning … cannot open display” (there appears to be a time at the three dots). Same if I try later to
lxc console ... --type=vga

I’ve had both virt-manager and spice-client-gtk installed while trying to get the vga working, but no luck - same error. Even uninstalled virt-manager to make sure spice was in charge, but same error.

And as an afterthought, when I installed the win11 VM, I had the same problem - didn’t get the console=vga to work. At that time I was able to go aroung the problem by using lxc web gui’s console to finish the graphical parts. Now it is not a solution. But altogether, the console=vga has never worked on my installation, as far as I know.

So, any ideas, what am I doing wrong, what have I missed? I’ve got some lxc monitor --debug output available, but it’s somewhat large with close to 6000 lines of output, it might have 2-3 attempts in it. If it would help, would you like it all or just some parts?

Finally, thank you already, LXD/LXC is a great product! I haven’t been very much into virtualization things before, but this has now inspired me a lot and opened my eyes to new possibilities.

Well, did some reading on virt-manager, and if I understood right, to work it requires an existing and working graphical environment, I guess like X server and a window manager running already. If this is true, I completely missed it from the lxc tutorials and other posts I found over internet. Well, there are many ways to learn.

I guess my goal is not possible with this approach, and I need to take a look at available lightweight and minimal desktops, ubuntu’s default gnome desktop feels a bit heavy and bloated for my needs.

If you see alternative solutions, I’d be very happy to hear.

And if this is the outcome, then I guess the topic title is a bit misleading. I’ll fix it after a while.

Is there an error “Authorization required” before Gtk-WARNING? If so, run xhost + to disable access control and try again lxc console --type=vga ubuntu (don’t forget turn it back xhost - later). If gui starts, you need to fix access. For example, you can add your user to the lxd group:

usermod -a -G lxd $USER
newgrp lxd

and run lxc without sudo.

1 Like