HOWTO: How to run graphics-accelerated GUI apps in LXD containers on your Ubuntu desktop

Here is an updated article on how to run GUI apps in a container, when LXD runs on your desktop computer.
The two requirements are to have hardware-acceleration for the graphics, and also have sound.
The tutorial shows off Firefox, Chromium and Chrome.
At the end, it creates a shortcut for the Firefox in LXD app and places it on the Launcher!


Thanks :slight_smile:
Great article !

Great article!

So here’s my question: Does anyone have this running in an ARCH container? I can’t get that working. I can provide more details if more are interested. The combination of an Ubuntu host with the AUR in a container is mouthwatering…

What part isn’t working specifically?

There really shouldn’t be any obvious cross-distro problem there. The X11 protocol is very backward and forward compatible.

1 Like

I believe it should be doable.

Can you go through your steps and point out where you actually get stuck?

I’m sorry for the late Reply.

I retried and had no issues… Worked great.

1 Like

Hi Simos, I have a question in the following post (IBus) Can not type Vietnamese on gui applications in container. Can you help me solve this problem?


Can you give me a guide on how to use ibus with Vietnamese?

@simos, re PulseAudio: on RPi 4 with host/guest Ubuntu 64-bit groovy 20.10

I wasn’t able to get “runcmd” part of profile executed, so in order to switch container’s pulseaudio into client mode, I had to manually execute “sed” command (or simply by editing respective config file).

It’s difficult for me to say if cloud-config part works at all - xclock/pulseaudio are available inside container, but dunno if that’s through “packages”, or “by default” in Ubuntu groovy

BTW, I took Ubuntu’s Desktop host image from RPI’s installer and cloud-init wasn’t part of it, so maybe I’ve missed some config step for it.

Maybe others with Raspberry Pi 4 and lxd/lxc have same issues.

If you got xclock installed in the container, then cloud-init worked for you. It is part of x11-apps and it’s not installed by default in the Ubuntu container images (or any other container image).

Note that you should be using the ubuntu:20.04 (or any ubuntu: container image), or if you use those from images:, it should be a container image that has /cloud in its name. The cloud means that the container image supports cloud-init.

It is OK if the host does not have cloud-init. The container image should have that package pre-installed. You can verify how well cloud-init ran for you, by looking at the file /var/log/cloud-init-output.log in the container.

I’ve used “images:ubuntu/20.10/cloud” and I do see records in container’s cloud-init log (connected to network mainly and adding packages like mesa-utils), but nothing re sed/runcmd/command (empty in grep).

I suggest to try as well with ubuntu:20.10. It is a cloud image.

If the runcmd commands do not run, then most likely there is a formatting issue in the LXD profile that does not let the container (cloud-init) to parse it. Note that LXD does not perform any checks on the content of the cloud-init text. You can have a look on how it has been parsed, in the appropriate /var/ subdirectory for cloud-init.