1

It is well known that you can run X11 applications in a docker container by passing /tmp/.X11-unix as a volume, setting DISPLAY appropriately, e.g. by forwarding it using -e DISPLAY=$DISPLAY and possibly also passing ~/.Xauthority as volume. This method requires that the docker daemon runs on your local machine, because only in that case forwarding the unix socket to access X11 into the container can possibly work.

If you are using Podman Desktop on windows though, there is no DISPLAY variable on Windows. If you enter a WSL unix container, you can access X11 (using WSLg) from that container, and you can access the podman daemon as remote server by following the instructions given in https://podman-desktop.io/docs/podman/accessing-podman-from-another-wsl-instance. You can't forward /tmp/.X11-unix though, because the docker daemon runs in a different machine (the podman system machine) than the WSL distribution.

Is there a straightforward way to run X11 applications in Unix containers using podman on Windows?

1 Answers1

0

You can run X11 applications in podman containers using Podman Desktop on windows. The podman system machine, that executes linux containers, is just another WSL machine that has access to WSLg. So you just have to forward the X11 socket from the podman system machine into the container. While forwarding /tmp/.X11-unix does not work, on WSL, this directory is meant to be forwarded to /mnt/wslg/.X11-unix anyway. Also, as WSLg only provides one X server anyway, the DISPLAY variable is always :0, so the following invocation of podman successfully executes X applications:

C:\Users\YourNameHere>podman run --rm -it -v /mnt/wslg/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 ubuntu:24.04
root@6ae01aaca1db:/# apt update && apt install xbill
...
root@6ae01aaca1db:/# /usr/games/xbill
(... playing game ...)
X connection to :0 broken (explicit kill or server shutdown).
root@6ae01aaca1db:/# exit

The error message appeared when I killed XBill after finding out that I am unable to play this game well using a trackpad on a laptop, and is standard behaviour of X11 applications if their main window is killed by closing it, it does not indicate any issue with the X11 environment.