rancher-sandbox / rancher-desktop

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

Not working with VS Code Devcontainers post v 0.266 #4436

Open robmaw opened 1 year ago

robmaw commented 1 year ago

Actual Behavior

The VSCode dev-containers extension underwent a change post v0.266 to support WSLG. Prior to this I was able to use Rancher Desktop fine with VS Code dev-containers. N.B. Docker Desktop continues to work with post 0.266 versions of VSCode dev-containers

Steps to Reproduce

Install Rancher desktop (v 1.8.1) Install VS Code Dev Containers extension > v0.266 (e.g. v0.288) Open VS Code and add devcontainer configuration files (any will do) Choose to reopen in container when prompted Observe failure when VS Code is trying to run the container.

[2023-04-13T05:09:02.617Z] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=c:\Repos\acrkiota3,target=/workspaces/acrkiota3,consistency=cached --mount type=volume,src=vscode,dst=/vscode --mount type=bind,src=\\wsl.localhost\Ubuntu-22.04\mnt\wslg\runtime-dir\wayland-0,dst=/tmp/vscode-wayland-b9e78a35-be27-4b15-8f70-59a2dea79843.sock -l devcontainer.local_folder=c:\Repos\acrkiota3 -l devcontainer.config_file=c:\Repos\acrkiota3\.devcontainer\devcontainer.json --entrypoint /bin/sh -l devcontainer.metadata=[{"id":"ghcr.io/devcontainers/features/common-utils:2"},{"id":"ghcr.io/devcontainers/features/git:1"},{"id":"ghcr.io/devcontainers/features/node:1","customizations":{"vscode":{"extensions":["dbaeumer.vscode-eslint"]}}},{"customizations":{"vscode":{"extensions":["ms-dotnettools.csharp"]}},"remoteUser":"vscode"},{"customizations":{"vscode":{"extensions":["Ionide.Ionide-fsharp","ms-dotnettools.csharp"]}}}] mcr.microsoft.com/devcontainers/dotnet:0-6.0-bullseye -c echo Container started
[2023-04-13T05:09:02.976Z] 
[2023-04-13T05:09:03.331Z] docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: \\wsl.localhost\Ubuntu-22.04\mnt\wslg\runtime-dir\wayland-0.

Result

[2023-04-13T05:09:02.617Z] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=c:\Repos\acrkiota3,target=/workspaces/acrkiota3,consistency=cached --mount type=volume,src=vscode,dst=/vscode --mount type=bind,src=\\wsl.localhost\Ubuntu-22.04\mnt\wslg\runtime-dir\wayland-0,dst=/tmp/vscode-wayland-b9e78a35-be27-4b15-8f70-59a2dea79843.sock -l devcontainer.local_folder=c:\Repos\acrkiota3 -l devcontainer.config_file=c:\Repos\acrkiota3\.devcontainer\devcontainer.json --entrypoint /bin/sh -l devcontainer.metadata=[{"id":"ghcr.io/devcontainers/features/common-utils:2"},{"id":"ghcr.io/devcontainers/features/git:1"},{"id":"ghcr.io/devcontainers/features/node:1","customizations":{"vscode":{"extensions":["dbaeumer.vscode-eslint"]}}},{"customizations":{"vscode":{"extensions":["ms-dotnettools.csharp"]}},"remoteUser":"vscode"},{"customizations":{"vscode":{"extensions":["Ionide.Ionide-fsharp","ms-dotnettools.csharp"]}}}] mcr.microsoft.com/devcontainers/dotnet:0-6.0-bullseye -c echo Container started
[2023-04-13T05:09:02.976Z] 
[2023-04-13T05:09:03.331Z] docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: \\wsl.localhost\Ubuntu-22.04\mnt\wslg\runtime-dir\wayland-0.

One key change after v0.266 is the additional mount for wslg:

...--mount type=bind,src=\\wsl.localhost\Ubuntu-22.04\mnt\wslg\runtime-dir\wayland-0,dst=/tmp/vscode-waylan...

Expected Behavior

The same command line executes correctly when using DockerDesktop:

[2023-04-13T04:56:44.340Z] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=c:\Repos\acrkiota2,target=/workspaces/acrkiota2,consistency=cached --mount type=volume,src=vscode,dst=/vscode --mount type=bind,src=\\wsl.localhost\Ubuntu-22.04\mnt\wslg\runtime-dir\wayland-0,dst=/tmp/vscode-wayland-94912031-9da9-4b68-a5b5-f8768bf6b0a3.sock -l devcontainer.local_folder=c:\Repos\acrkiota2 -l devcontainer.config_file=c:\Repos\acrkiota2\.devcontainer\devcontainer.json --entrypoint /bin/sh -l devcontainer.metadata=[{"id":"ghcr.io/devcontainers/features/common-utils:2"},{"id":"ghcr.io/devcontainers/features/git:1"},{"id":"ghcr.io/devcontainers/features/node:1","customizations":{"vscode":{"extensions":["dbaeumer.vscode-eslint"]}}},{"customizations":{"vscode":{"extensions":["ms-dotnettools.csharp"]}},"remoteUser":"vscode"},{"customizations":{"vscode":{"extensions":["Ionide.Ionide-fsharp","ms-dotnettools.csharp"]}}}] mcr.microsoft.com/devcontainers/dotnet:0-6.0-bullseye -c echo Container started
[2023-04-13T04:56:44.684Z] 
[2023-04-13T04:56:45.521Z] Stop (1181 ms): Starting container

i.e.

Additional Information

No response

Rancher Desktop Version

1.8.1

Rancher Desktop K8s Version

n/a

Which container engine are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Wiondows 11 Enterprise 22H2 22624.1546

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

N/A

robmaw commented 1 year ago

Windows 11 Enterprise 22H2 22624.1546

OneCyrus commented 1 year ago

we have the same issue.

workaround for now is to disable wayland in the devcontainer settings.

"customizations": {
    "vscode": {
      "settings": {
        "dev.containers.mountWaylandSocket": false
      }
    }
  }
gunamata commented 1 year ago

@robmaw , I am not sure if it's something specific to the extension version and/or the dev container being used in your case.

I could get the javascript-node dev container working with Dev Containers extensions version v0.288.1 and Rancher Desktop 1.8.1

May be a good idea to document the workaround suggested above as a Troubleshooting tip? @sunilarjun

sunilarjun commented 1 year ago

@gunamata I think that's a good idea, I'll work on getting a PR up for the docs!

shikanime commented 1 year ago

It seems like an issue with the daemon cri-dockerd which doesn't support this platform specific mount syntax, that could also be a SMB server. Maybe something have to be one around here github.com/Mirantis/cri-dockerd/core/helpers_windows.go

shoddyguard commented 1 year ago

we have the same issue.

workaround for now is to disable wayland in the devcontainer settings.

"customizations": {
   "vscode": {
     "settings": {
       "dev.containers.mountWaylandSocket": false
     }
   }
 }

You can also disable this globally in your user settings under extensions if you prefer to do things that way. If you use the Open User Settings (JSON) command then it's exactly the same key as above. ("dev.containers.mountWaylandSocket": false)