3 ms·
I didn't know you could run graphical apps in Docker. How does that work?
by crummy 7y ago
I didn't know you could run graphical apps in Docker. How does that work?
- Arnavion 7y agorm -f ~/docker-games/root/.Xauthority touch ~/docker-games/root/.Xauthority xauth nlist "$DISPLAY" | sed -e 's/^..../ffff/' | xauth -f ~/docker-games/root/.Xauthority nmerge - chmod 0444 ~/docker-games/root/.Xauthority XSOCK="$(realpath /tmp/.X11-unix/*)" DBUS_SESSION_BUS_PATH="$(echo "$DBUS_SESSION_BUS_ADDRESS" | sed -e 's/^unix:path=//')" docker run -it --rm \ --device '/dev/dri:/dev/dri' \ -v "$XSOCK:$XSOCK" \ -v "$(realpath ~/docker-games/root):/home/arnavion" \ -v "$(realpath ~/.config/pulse/cookie):/home/arnavion/.config/pulse/cookie" \ -v "$DBUS_SESSION_BUS_PATH:$DBUS_SESSION_BUS_PATH" \ -e "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" \ -e "DISPLAY=$DISPLAY" \ -e "PULSE_SERVER=$(ip -4 addr show enp4s0 | grep -Po 'inet \K[^/]+'):4713" \ -e 'XAUTHORITY=/home/arnavion/.Xauthority' \ --shm-size '1G' \ --hostname arnavion-docker-games \ docker-games \ $COMMAND The XSOCK mount allows it to talk to the host X server, and the .Xauthority mount allows it to auth with the host X server. Apart from that: * ~/docker-games/root is the home directory inside the container. * The DBUS mount and env var is to allow Steam to show its icon in the system tray of the host DE. There's also a symlink for `~/.steam/public/steam_tray_mono.png` -> `~/docker-games/root/.steam/public/steam_tray_mono.png` so that the host DE can find the icon based on the path inside the container. * The pulseaudio mount and env var is to allow sound. It requires pulseaudio to be set up to allow network clients. Here's the full gist: https://gist.github.com/Arnavion/3212232d0761d49d9636f796c5a99e53 https://gist.github.com/Arnavion/3212232d0761d49d9636f796c5a...