mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.5k stars 370 forks source link

Run X11 server on Ubuntu Server Installtion? #517

Open stsichler opened 7 months ago

stsichler commented 7 months ago

Hi, I'm trying to start an X11 server in a podman container on an Ubuntu 22.04.3 LTS Server installation (no X11) on my RasPi4b. So I do not have any X11 related stuff on my host system. The device only shows TTY consoles on HDMI screen. Can x11docker be used to start an isolated X11 server here or does it require a running X11 server on the host?

I've pulled the x11docker/xserver image and I'm starting x11docker with x11docker -D --xc=podman --size=1280x720 --xorg --xonly but I only get errors:

x11docker note: --xorg cannot claim a new virtual terminal (option --vt) with rootless X container (option --xc). Please see also the full error log.

What can I do?

echuber2 commented 7 months ago

I'm not sure in your particular case, but it sounds like the error is happening because you're trying to use rootless podman as the backend, but this combination of options wants to do something that requires a rootful backend. Maybe try with --backend=podman --rootless=yes --xc=yes or try running directly from a tty.

stsichler commented 7 months ago

It turned out that running sudo x11docker --debug --backend=podman --xc=podman --rootless=yes --xorg --desktop --vt=8 --gpu --network --xonly seems to be the right way. But then, X11 cannot start because of error [(EE) no screens found(EE)]. I found out, that that can be fixed by adding --device /dev/fb0 to the podman run command.

After adding that to x11docker, the X11 server opens and I can see the black X-shaped cursor :+1: , but then it fails to add any input devices, see this verbose-log.txt.

Hm, looking through the log, it seems that adding /dev/fb0 should not be necessary at all, but there seems to also be a problem with DRI, indicated by the lines

(II) xfree86: Adding drm device (/dev/dri/card1)
(EE) /dev/dri/card1: failed to set DRM interface version 1.4: Function not implemented
(II) xfree86: Adding drm device (/dev/dri/card0)
(EE) /dev/dri/card0: failed to set DRM interface version 1.4: Function not implemented

Any ideas?

echuber2 commented 7 months ago

You're running with sudo, so do you really need rootless podman? I would try it with (rootful) docker in the most default way possible first, like the examples. You could try some of the other options like xephyr as well.

I should say that I haven't tried using this on a RPi or with Podman, and I'm not the maintainer of this project, so I can only guess. There are other errors and warnings in your log, for example:

_XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root _XSERVTransmkdir: Mode of /tmp/.X11-unix should be set to 1777 _XSERVTransmkdir: this may cause subsequent errors

Also a few mentions of AppArmor. I don't know if the DRI issue is something related to your kernel drivers or a capabilities limitation. There are a few other things like this:

(II) FBDEV(0): FBIOBLANK: Function not implemented (Screen blanking not supported by kernel - disabling)