Live data from Hacker News

How to run GUI applications directly in containers

github.com

21–30 of 40 posts

Re: How to run GUI applications directly in containers

#22
post #17

Is this solution different from just executing this: docker run -it --rm -e DISPLAY --net=host -v $XAUTHORITY:/root/.Xauthority -v /tmp/.X11-unix:/tmp/.X11-unix debian:12-slim And then run the GUI app in the container? For example for Firefox: apt update apt install firefox-esr firefox That is an approach I sometimes use to try GUI applications in a Docker container.

The approach uses Wayland and Pipewire.

> When you start a container instance, all you need to do is map the host's Wayland socket and PipeWire socket files into the container, and then set the appropriate environment variables within the container to enable running GUI applications.

Re: How to run GUI applications directly in containers

#25
post #17

Is this solution different from just executing this: docker run -it --rm -e DISPLAY --net=host -v $XAUTHORITY:/root/.Xauthority -v /tmp/.X11-unix:/tmp/.X11-unix debian:12-slim And then run the GUI app in the container? For example for Firefox: apt update apt install firefox-esr firefox That is an approach I sometimes use to try GUI applications in a Docker container.

Isn't this working just for X11?

Should also work with xwayland, but yes.

Re: How to run GUI applications directly in containers

#26

Using x11 :) the concept is nice, and could help isolate much more elegant than qubes for example. But the protocol sucks I’ve heard

? This is explicitly wayland, not x11. And x11 isn't likely to give you very good isolation unless you jump through hoops.

Re: How to run GUI applications directly in containers

#28
I configure all my development containers to mount my host's Wayland socket. It mostly Just Works, and obviates the need to do any shell shuffling if I need to run something with a graphical component.

It's also occasionally convenient if I need to run a GUI app written in (say) Java that requires a zillion megabytes of JVM dependencies - just spin up an ephemeral container that makes everything disappear on CTRL-D.

Re: How to run GUI applications directly in containers

#29
post #6

I don't want to be negative but Flatpak is a container runtime specifically designed for GUI apps and Docker isn't.

But doesn't flatpack offer much deeper system Integration by default? Like being able to access the home directory by default and being able to talk to dbus? To me flatpack looks like a way achieve application compatibility not security

By default a flatpak has no permissions. It exposes ways to add permissions both statically and dynamically. So security varies.

Re: How to run GUI applications directly in containers

#30
post #27

The linuxserver.io packaged a couple popular GUI apps in container, e.g. Calibre. The container packages a VNC server, and you can access the container using a webVNC. This seems like a great solution for non-GPU-intensive GUI apps.

I remember having to do something similar when I was running a Debian chroot on an Android phone on one of the early Android phones.

Haven’t stuck around so I don’t know if VNC is still common to use locally on Android when you want to run other Linux distros with graphical environments on your device.

It worked but having to rely on VNC for something that is local on the same machine never felt great to me. Same when I VNC into a VM on the same host. It just feels a bit wrong to me to have to use VNC. It works and I do it sometimes for VMs on my computer, but I don’t like it.

The cool people do things like PCI passthrough. But I don’t have an extra graphics card and I haven’t looked much at the details of PCI passthrough anyways. Seems like a lot of effort also.

I do like X11 forwarding. I don’t know what to do for Wayland when it’s a VM.

Post reply on HN