Running KDE in a LXD container ... is it Possible?

I would like to run Ubuntu 18.10 w/ KDE Plasma 5 within a LXD container. Not particularly knowing what I am doing, I set up a container with Ubuntu 18.10 and then once in the container installed thed plasma-desktop from the Ubuntu repository. Everything installed without error but I cannot get the Desktop to run. I have tried “xinit” and “startx” commands but get this error:

(EE) parse_vt_settings: Cannot open /dev/tty0 (No such file or directory)

further investigation shows that the container does not have a “tty0” just a tty. I am certain there is much I need to set up but haven’t. A push in the right direction would be appreciated :):grin:

There have been a few discussions about this, how to run a X server in a container while there is also a X server running on the host. My understanding is that you can’t run two separate X servers with hw acceleration and all on the same gpu, because each needs exclusive access to the GPU.

Having said that, it should be possible to create two displays ($DISPLAY) with the host’s X server and direct the container’s desktop to the second display. That is, do not launch an X server in the container but only the desktop environment. You switch between them with a shortcut like Ctrl-Alt-F6.

Alternatively, you can use something like a software X server like Xephyr so that you get the output in a window of your desktop instead.

My question is why would you want to do this? The whole point of an X server is to allow X clients (i.e. X graphical applications) from multiple locations to all display to the same server. If you’re testing out DEs (desktop environments) then a full-blown VM is probably a better way to go.

It’s an issue of not using too many resources.
Like, why use LXD when you can create VMs?

It is possible to run X11 apps in a LXD container and get the output on your Linux desktop.

It is also possible to run a desktop in a LXD container using X2Go,

It should be possible to run a distro from a LXD container and have it appear on a separate X11 DISPLAY.

The primary reason is that I have PiHole running in a LXD container - obtaining its IP via macvlan - therefore the host - which was running KDE - could not utilize PiHole as its DNS resolver (as configured). Thats really about it haha

But how does running Plasma in the container help you with this?

Well unless I am wrong, containers can ping each other. Thus a Plasma container would be able to ping the PiHole container permitting it utilize its DNS services and allowing me to have a Linux desktop that would benefit from PiHole (without additional hardware). If there is way for the host to utilize the PiHole container as its DNS server I’d prefer that but I utilize macvlan to assign IP’s to the containers so the rest of the network can utilize the PiHole. Again, as I understand it, utilizing macvlan prevents the host from “talking” to the container over LAN.

I suppose I could make the host the Desktop and Pihole but PiHole bogarts the webserver on the host machine preventing me from running, for instance, nextcloud. Alternatively, I could just do that and put nextcloud in a container but then the Host would not have access to that.

I am spitballing because I am a linux/LXD novice/hobbiest/enthusiast … I am interested enough to dive deep and really understand these topics. I’m just not there yet. Hopefully I can stand on the shoulders of the resident giants in the meantime :slight_smile:

The whole macvlan containers not being able to talk to the host has been bothering me, so I dug into it a bit. You’re on the right track with this post: Host to Container connection with macvlan bridge

The correct solution is to figure out how to get your host to talk to the macvlan container. You already found the old solution provided here:

Another possibility is to move your primary host interface to a bridge and then use that same bridge for your containers, as described here:

Both of those links are pretty old, at this point, so there might be a better way to do this altogether (also depending on what version of lxd you’re using). I’ve used netplan a little, but not enough to advise you on how to implement either of these or other more sophisticated setups, but if you figure it out, can you post the solution to Host to Container connection with macvlan bridge ? Thanks

1 Like


Thank you for your thoughtful reply. I apologize for being so late in my response. I ultimately dumped the hole KDE idea because I found myself 99% in command line any way.

However, it appears Mr. Pibb has found a solution! HERE (Host to Container connection with macvlan bridge). I have yet to try it but it looks promising!

This sounds very interesting. Do you know if there’s been any further headway on doing this sort of thing since you posted on this? Or if anyone has written about how to run a full DE from a container on a second display? I’m not totally sure how to go about this, but I’d like to try and figure it out.

I did not make any further headway. I went a different route and installed ProxMox on a desktop I had lying around. Now when I want to test a DE I just spin up a VM.