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 1 year 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

How are you running the WSL2 Linux containers? Are you running Docker Desktop for that? AFAIK, you can't run both with the Docker engine, you need to change the docker engine parameters to run either Linux or Windows.

vrapolinario avatar Sep 05 '24 15:09 vrapolinario

How are you running the WSL2 Linux containers? Are you running Docker Desktop for that? AFAIK, you can't run both with the Docker engine, you need to change the docker engine parameters to run either Linux or Windows.

I don't have Docker Desktop on my system; I installed the Linux Docker Engine on my WSL2 Ubuntu instance (and as mentioned in my original post, I installed the Windows Docker Engine on Windows today). Starting a Windows container on Docker Engine for Windows doesn't have any impact on my running WSL2 containers, and vice versa. Running docker ls on Windows only shows my Windows containers, running the same in WSL2 shows only Linux containers.

rsenden avatar Sep 05 '24 15:09 rsenden

Triaging to the broader team to get more eyes on this.

ntrappe-msft avatar Oct 02 '24 17:10 ntrappe-msft

Hi @rsenden can you give us detailed repro steps so we can see exactly how you set up your system and what you're testing/trying?

ntrappe-msft avatar Mar 04 '25 20:03 ntrappe-msft

Hi @rsenden, I am unable to reproduce this on Windows 11 Pro 23H2 (22631.5189) in a Hyper-V VM with nested virtualization and up to 8 GB of RAM, with Ubuntu 24.04.2 LTS in WSL 2, VcXsrv 21.1.16.1, and Docker CE 28.0.4. I configured VcXsrv as above, with the host IP address in DISPLAY and auth disabled. I ran Google Chrome 135.0.7049.84 in Ubuntu under WSL 2. I then created a Docker container as above. The Chrome window continued working.

Will you please try again with the latest versions and let us know if you can still reproduce it? It would also help to provide detailed instructions on how VcXsrv is configured, and the X configuration in Ubuntu. Thanks.

johnstep avatar Apr 08 '25 22:04 johnstep

We have been unable to reproduce this. Please let us know if you still can. Thanks.

johnstep avatar Apr 29 '25 17:04 johnstep