GUI Apps in LXD container

Thanks, everything works now.

Also I realized the error in my previous attempts was that the container and the host did not have the same exact version of the nvidia drivers (they were both 430, but different minor version) because in the host I had the graphics-drivers PPA enabled!

Thanks again for the help and for the useful guides!

Hi All!

Simos, first of all thank you for your answers. I also try use GUI app in LXD.
My host worsk on CentOs7 and my lxd also works on CentOS7. And… xclock works fine, but glxgears shows a black window and some errors in terminal:
libGL error: unable to load driver:
libGL error: failed to load driver: swrast

I tryed to install nvidea driver in container but failed. Installer disaplay: “An NVIDIA kernel module ‘nvidia-drm’ appears to already be loaded in your kernel…”

Could you help me to figure out ?

Thanks in advance.


The error message says that it could not find any GPU GL (acceleration) libraries in the container.

The container needs to get the GPU libraries, and one way to do so, is by installing the full GPU drivers.
Now, depending on the distribution, you might get such an error that the kernel module for the GPU is already installed, because indeed the kernel driver is installed, on the host.
From what you tell me about CentOS, the full GPU package installation fails in the container because it requires to successfully install the whole lot.

There are two ways to bypass this problem.

  1. See which is about Debian/Ubuntu, and shows how to install GPU libraries but not the GPU kernel package. And try to replicate for CentOS (I do not use CentOS).
  2. See this post, GUI Apps in LXD container on how to use the NVidia Runtime in the container. This should become the preferred way. You need to set nvidia.runtime and nvidia.driver.capabilities in the container for this to work.
1 Like


I tryed to implement approach #2. I replaced my gui profile to profile for nvidia and container not started:
lxc start centos7
Error: Failed to run: /snap/lxd/current/bin/lxd forkstart centos7 /var/snap/lxd/common/lxd/containers /var/snap/lxd/common/lxd/logs/centos7/lxc.conf:
Try lxc info --show-log centos7 for more info

lxc info --show-log centos7
Name: centos7
Location: none
Remote: unix://
Architecture: x86_64
Created: 2019/08/26 12:56 UTC
Status: Stopped
Type: persistent
Profiles: inet, nvidia


lxc centos7 20190829115158.804 ERROR    conf - conf.c:run_buffer:352 - Script exited with status 1
lxc centos7 20190829115158.804 ERROR    conf - conf.c:lxc_setup:3653 - Failed to run mount hooks
lxc centos7 20190829115158.804 ERROR    start - start.c:do_start:1321 - Failed to setup container "centos7"
lxc centos7 20190829115158.804 ERROR    sync - sync.c:__sync_wait:62 - An error occurred in another process (expected sequence number 5)
lxc centos7 20190829115158.804 WARN     network - network.c:lxc_delete_network_priv:3377 - Failed to rename interface with index 61 from "eth0" to its initial name "vethe03092da"
lxc centos7 20190829115158.804 ERROR    lxccontainer - lxccontainer.c:wait_on_daemonized_start:873 - Received container state "ABORTING" instead of "RUNNING"
lxc centos7 20190829115158.805 ERROR    start - start.c:__lxc_start:2039 - Failed to spawn container "centos7"
lxc 20190829115158.953 WARN     commands - commands.c:lxc_cmd_rsp_recv:135 - Connection reset by peer - Failed to receive response for command "get_state"


I want to render with OpenGL in LXD without an X Server in host. what can I do ?


I suppose you only need the OpenGL libraries to be available in the container, and have access to the GPU from the container.

To give access to your GPU inside the container, you need to run (from the host) the following. If you have more than one GPU, you may need to add parameters that distinguish one from another.

lxc config device add mycontainer mygpu gpu

If you have an Intel or AMD GPU or Nvidia (nouveau), then you would need to install the corresponding GL libraries (mesa). Sorry, I do not have the proper list handy at the moment.

If you have an NVidia GPU (closed-source driver on the host), it used to be much harder but now it is apparently easier because Nvidia distributes a runtime and LXD can use it. In that case, you can run from the host,

lxc config set mycontainer nvidia.runtime true
lxc restart mycontainer

Can you show what’s in the nvidia profile?

The command is:

lxc profile show nvidia

I got the answer by myself. Thanks.

If I recollect correctly, you have been trying to run OpenGL applications on a AWS server that has an NVidia GPU, and all than in a container. I have no experience with that and I do not know what to suggest.

Can you give us a summary on how you resolved the issue?