Windows-Containers icon indicating copy to clipboard operation
Windows-Containers copied to clipboard

WSL2 Missing X server when running Windows Docker container

Open rsenden opened this issue 5 months ago • 3 comments

I've been successfully running WSL2 Ubuntu on my company-managed Windows 11 Pro 23H2 (OS build 22631.4037) workstation. For Linux GUI applications, I'm using the following setup (due to some earlier issues with WSLg):

  • guiApplications=false in .wslconfig
  • VcXsrv on Windows as the X server
  • DISPLAY=:0
  • LIBGL_ALWAYS_INDIRECT=1

I'm also building and running Linux Docker containers in this WSL2 instance, but I don't think this is related to the issue below.

Today, I installed Docker CE engine on Windows to allow for building and running Windows images, using instructions provided at https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce#windows-server-1. All good so far; after a reboot I can still run X applications from my WSL2 instance.

However, as soon as I run a Windows container, for example by running docker run --rm -it mcr.microsoft.com/windows/nanoserver:ltsc2022 cmd.exe from a PowerShell or CMD.exe console, all my WSL2 GUI applications disappear. Attempting to start a new GUI application from my WSL2 instance (in this example Google Chrome) shows the following error messages:

[10982:10982:0905/163020.111216:ERROR:ozone_platform_x11.cc(244)] Missing X server or $DISPLAY
[10982:10982:0905/163020.111406:ERROR:env.cc(258)] The platform failed to initialize.  Exiting.

Stopping or removing the Windows container doesn't help; the only way I've found so far to recover from this situation is by rebooting my machine. Any ideas as to why this may be happening, or how to troubleshoot or fix this issue?

rsenden avatar Sep 05 '24 14:09 rsenden