Running GUI Apps in Docker

Last update: 2026-05-12 09:25:53 +0800 CST
tags: Docker | GUI

I’m running Archlinux with Wayland, so ideally a wayland-native solution will be more satisfying, but it turned out that interfacing with the xwayland adapter isn’t that bad in term of performance.

sh
#!/bin/bash

# x11 socket dir
S='/tmp/.X11-unix'

# magic cookie file on host
M=$(realpath /run/user/1000/.mutter-*)

echo "----- $M -------"

# magic cookie file in guest
XA='/tmp/xauthee'

docker run -it --entrypoint bash --user jose \
    -v $S:$S -v $M:$XA \
    -e DISPLAY=:0 -e XAUTHORITY=$XA \
     debian:bookworm-slim

I’m installing my GUI apps from a standalone DEB, in the container, a simple apt install will brings all the GTK and libX11.

If you need better performance or container streaming solution like kasm.com, consider using VNC-based solutions.