Forward to container whole video adapter

Hello there.
I know this question has been asked many times, but almost all the cases I could find assume that X11 exist on the host for forwarding separate application from container (for example), I need to forward the entire X11 session from the container to a video output of host which does not have X11. Is it possible?

Well, that depends:

  • What software does your host use instead? Or is it headless?
    There are for example solutions available for Wayland as well (just search the forum).

Many methods (for X-forwarding) assume that you want to use a X-Server of the Host inside the container (this is e.g. because of better performance=GPU accerleration).

Your case seems to be the opposite :thinking:.

According to this:


There is only a tutorial for LXC about running a X-Server inside a container (I haven’t looked at it):

Notice though that you probably also need to have devices like /dev/video on your host.
If you don’t have these devices, I would search for whether it is possible to run an X-Server on a pure server hardware.
Maybe Virtual machines would also work better in such a case.
Sry no expert :man_shrugging:.

Assuming this works, then you could use a remote-desktop software like vnc or ssh -x etc. to login to your containers desktop.

But maybe someone else has a better idea.

Hi @toby63, thanks for the fast reply!

What software does your host use instead? Or is it headless?

Thats right, my host is headless

Assuming this works, then you could use a remote-desktop software like vnc or ssh -x etc. to
login to your containers desktop.

Unfortunately, I cant use x-forward over ssh or VNC cause have no GUI on my host system :frowning:

Thanks anyway :slight_smile:

:thinking: I haven’t tried it, but it seems you might be able to use something like this:
https://techoverflow.net/2019/02/23/how-to-run-x-server-using-xserver-xorg-video-dummy-driver-on-ubuntu/

I assume that it should be possible to either:

  1. Forward the Socket of this X-Server to your container, so every application or even the whole desktop inside the container can use it (similar to the instructions from simos blog you already mentioned (running-x11-software-in-lxd-containers))
    or
  2. Run this inside the container itself (not sure whether that is possible)

An important thing to keep in mind is that the X-Server is not so good for a host<->container scenario because it allows applications access to other applications windows (so it essentially breaks the seperation between host and container in this regard).
Thats why I prefer Wayland, but I don’t know if such a dummy server exists yet for Wayland as well.

If your host is headless and you plan to run the entire X server in a container, then I think it cannot be done with unprivileged container.
You can run CUDA programs though.