This is Windows 11 running Ubuntu via WSL2, with Docker Desktop v4.32.0. The Windows Defender Firewall is OFF.
The WSL command-line runs Linux command-line containers just fine. I need X-Windows clients in the container, so in building the container:
RUN apt update && apt install -y xserver-xorg-core xserver-xorg xorg xterm
After doing “xhost +” on my Mac, xclock in the container will display on my Mac. But I have been unable to get xclock in the container to display on the Windows desktop (which is where I need it). Indeed, after doing “xhost +” in WSL, the Mac cannot display on the Windows desktop either.
Note that WSL2/Ubuntu does support X-Windows, and when run from the WSL command line xclock does display on the Windows desktop. But Windows is rather picky about how you connect to the DISPLAY:
(WSL command line)
ip address
… inet 192.168.1.235/24 …
echo $DISPLAY
:0
xclock – works
DISPLAY=:0 xclock – works
xhost +
DISPLAY=localhost:0 xclock – hangs without display
DISPLAY=localhost.local:0 xclock – Error: can’t open display
DISPLAY=192.168.1.235:0 xclock – Error: can’t open display
For the container, I have tried all variations I can think of with and without “–net host” and variations on DISPLAY. None display on the Windows desktop. The problem is probably related to the last line above using the Windows IP in DISPLAY – if that fails, no external X-Windows client can display on the Windows desktop. And it thinks the container is external, even with “–net host”.
How do I configure this so xclock (and other X-Windows clients) inside the Linux container will display on the Windows desktop? (I’m willing to do “xhost +”.)