microsoft / Windows-Containers

Welcome to our Windows Containers GitHub community! Ask questions, report bugs, and suggest features -- let's work together.
MIT License
408 stars 64 forks source link

WSL2 Missing X server when running Windows Docker container #529

Open rsenden opened 1 week ago

rsenden commented 1 week ago

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):

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?

vrapolinario commented 1 week ago

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.

rsenden commented 1 week ago

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.