rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.75k stars 271 forks source link

WSL2: VS Code Dev Containers have no GUI support with the default rancher-desktop WSL2 distro #7163

Open imphil opened 3 weeks ago

imphil commented 3 weeks ago

Summary: As Windows user, I want to run graphical applications in a VS Code Dev Container with the default installation of Rancher Desktop. Currently, that doesn't work with the default rancher desktop WSL2 distro, but only with a separately installed and configured Ubuntu WSL2 distro.

User Setup:

Background:

The problem: With a default installation of Rancher Desktop, the Alpine Linux-based rancher-desktop WSL2 distro is used to run Dev Containers in VS Code (since it's the only and default WSL2 distro available in a clean installation). This WSL2 distro does not (for yet unknown reasons) work with WSLg, ultimately resulting in users not being able to run GUI applications in their Dev Container (the DISPLAY environment variable is not set).

Workaround: With the Ubuntu WSL2 distro, graphical applications work in containers. I.e., the workaround is: Install the ubuntu WSL2 distro, set it as default in WSL2, and configure Rancher Desktop to expose the docker daemon to it.

Question: I'm happy to investigate further why the X forwarding doesn't work with the rancher-desktop WSL2 distro. But before I do so: is it the intended use case of the rancher desktop WSL2 distro to run containers in there? Or is this distro only meant to run docker itself, and users should use another WSL2 distro to actually run their containers (I think that's how Docker Desktop operates). Ultimately, I'm looking for a solution that works as easily as possible for the user, the less additional steps they have to take at installation time, the better.

gunamata commented 2 weeks ago

As the information about the actual dev container used is not provided, I have tried installing a simple GUI app (one of the sample apps provided in the wslg repo's README page) and could reproduce the behavior you described in the issue description, i.e. the GUI app not working within the rancher-desktop distro but working within a Ubuntu distro, which makes me also think that it's some alpine-wslg compatibility/configuration issue and I do not have anything on top of my head to suggest for a fix.

I'm happy to investigate further why the X forwarding doesn't work with the rancher-desktop WSL2 distro.

Yes please. It would be great if you can explore further and could figure out a way to get wslg working within the default rancher-desktop distro. If you have success, please do share your learnings here.

Or is this distro only meant to run docker itself, and users should use another WSL2 distro to actually run their containers in there?

Yes, it's by design that the core components such as the container engine, kubernetes etc run in the rancher-desktop distro and hence the containers actually run in the distro as well. To my knowledge there's no way to run containers in other distros you expose Rancher Desktop's configuration to. Exposing the Rancher Desktop's configuration to other distros just allows you to interact with the container engine, containers etc running in the rancher-desktop distro.