rancher-desktop icon indicating copy to clipboard operation
rancher-desktop copied to clipboard

WSL2 VSCode devcontainer bind mount fails

Open jacobbonde opened this issue 2 years ago • 3 comments

Actual Behavior

Opening a VS Code devcontainer fails. The code that I'm trying to open exists in a WLS2 ubuntu instance. For the purpose of this bug report, I'm using the javascript-node sample as used in your How-to guide, but the problem is the same with my own code projects.

Steps to Reproduce

Follow the How-to guide until step 7.

Result

The container never opens, but fails with this error in the log:

[2022-08-22T10:50:54.412Z] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/<redacted-username>/<redacted>/vscode-dev-containers,target=/workspaces/vscode-dev-containers --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\\wsl$\Ubuntu\home\<redacted-username>\<redacted>\vscode-dev-containers\containers\javascript-node --entrypoint /bin/sh vsc-javascript-node-ea50e84ef9163809fbe003b08f12d0b8-uid -c echo Container started
[2022-08-22T10:50:55.831Z] docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /wsl/rancher-desktop/run/docker-mounts/11aac75c-a18e-450f-8495-1aaf15a866ec.
See 'docker run --help'.

Expected Behavior

I expected VS Code to open the code in the devcontainer

Additional Information

No response

Rancher Desktop Version

1.5.1

Rancher Desktop K8s Version

1.24.3

Which container engine are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Windows 10 Enterprise, 19044

What CPU architecture are you using?

x64

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

No response

Windows User Only

No response

jacobbonde avatar Aug 22 '22 11:08 jacobbonde

Below steps worked for me.. Can you please try these steps and let me know if it works for you and serves your need

  • Clone the sample inside the WSL distro - git clone https://github.com/microsoft/vscode-dev-containers.git
  • Use Open Folder in WSL option to open the javascript-node folder in VS Code
  • VS Code detects the .devContainer folder and offers to reopen the workspace in a container. Accept.
  • Once the container image is built, run and ready. Hit F5 to run and test the sample app.
  • Make code changes, Re run the app.

gunamata avatar Aug 23 '22 00:08 gunamata

Yes, this is basically what I did and described in the OP. I just did it again, following your steps exactly:

✅ Clone the sample inside the WSL distro - git clone https://github.com/microsoft/vscode-dev-containers.git ✅ Use Open Folder in WSL option to open the javascript-node folder in VS Code ✅ VS Code detects the .devContainer folder and offers to reopen the workspace in a container. Accept. ❌ Once the container image is built, run and ready. Hit F5 to run and test the sample app. ⬜ Make code changes, Re run the app.

The image does not run. These errors are in the log:

[...] [2022-08-24T09:45:00.614Z] Successfully built e09ec152e2eb [2022-08-24T09:45:00.620Z] Successfully tagged vsc-javascript-node-ea50e84ef9163809fbe003b08f12d0b8-uid:latest [2022-08-24T09:45:00.626Z] Stop (2438 ms): Run: docker build -f /tmp/vsch-jbl/updateUID.Dockerfile-0.245.2 -t vsc-javascript-node-ea50e84ef9163809fbe003b08f12d0b8-uid --build-arg BASE_IMAGE=vsc-javascript-node-ea50e84ef9163809fbe003b08f12d0b8 --build-arg REMOTE_USER=node --build-arg NEW_UID=1000 --build-arg NEW_GID=1000 --build-arg IMAGE_USER=root /tmp/vsch-jbl [2022-08-24T09:45:00.628Z] Start: Run: docker -v [2022-08-24T09:45:02.372Z] Stop (1744 ms): Run: docker -v [2022-08-24T09:45:02.373Z] Start: Run: docker events --format {{json .}} --filter event=start [2022-08-24T09:45:02.468Z] Start: Starting container [2022-08-24T09:45:02.468Z] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/jbl/redacted/vscode-dev-containers,target=/workspaces/vscode-dev-containers --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node --entrypoint /bin/sh vsc-javascript-node-ea50e84ef9163809fbe003b08f12d0b8-uid -c echo Container started [2022-08-24T09:45:03.602Z] docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /wsl/rancher-desktop/run/docker-mounts/0f204773-f40e-4c1a-84e0-e4255b4e3b9f. See 'docker run --help'. [2022-08-24T09:45:03.603Z] Stop (1135 ms): Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/jbl/redacted/vscode-dev-containers,target=/workspaces/vscode-dev-containers --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node --entrypoint /bin/sh vsc-javascript-node-ea50e84ef9163809fbe003b08f12d0b8-uid -c echo Container started [2022-08-24T09:45:03.604Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node [2022-08-24T09:45:03.699Z] Stop (1326 ms): Run: docker events --format {{json .}} --filter event=start [2022-08-24T09:45:05.585Z] Stop (1981 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=\wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node [2022-08-24T09:45:05.587Z] Error: Command failed: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/jbl/redacted/vscode-dev-containers,target=/workspaces/vscode-dev-containers --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node --entrypoint /bin/sh vsc-javascript-node-ea50e84ef9163809fbe003b08f12d0b8-uid -c echo Container started [2022-08-24T09:45:05.588Z] trap "exit 0" 15 [2022-08-24T09:45:05.588Z] exec "$@" [2022-08-24T09:45:05.588Z] while sleep 1 & wait $!; do :; done - [2022-08-24T09:45:05.589Z] at MS (/home/jbl/.vscode-remote-containers/dist/dev-containers-cli-0.245.2/dist/spec-node/devContainersSpecCLI.js:255:2186) [2022-08-24T09:45:05.589Z] at Zw (/home/jbl/.vscode-remote-containers/dist/dev-containers-cli-0.245.2/dist/spec-node/devContainersSpecCLI.js:255:2124) [2022-08-24T09:45:05.589Z] at processTicksAndRejections (node:internal/process/task_queues:96:5) [2022-08-24T09:45:05.589Z] at async KS (/home/jbl/.vscode-remote-containers/dist/dev-containers-cli-0.245.2/dist/spec-node/devContainersSpecCLI.js:261:2006) [2022-08-24T09:45:05.589Z] at async co (/home/jbl/.vscode-remote-containers/dist/dev-containers-cli-0.245.2/dist/spec-node/devContainersSpecCLI.js:261:3110) [2022-08-24T09:45:05.590Z] at async LP (/home/jbl/.vscode-remote-containers/dist/dev-containers-cli-0.245.2/dist/spec-node/devContainersSpecCLI.js:360:9352) [2022-08-24T09:45:05.590Z] at async DP (/home/jbl/.vscode-remote-containers/dist/dev-containers-cli-0.245.2/dist/spec-node/devContainersSpecCLI.js:360:9108) [2022-08-24T09:45:05.595Z] Stop (16496 ms): Run in Host: /home/jbl/.vscode-server/bin/e4503b30fc78200f846c62cf8091b76ff5547662/node /home/jbl/.vscode-remote-containers/dist/dev-containers-cli-0.245.2/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/jbl/redacted/vscode-dev-containers/containers/javascript-node --workspace-mount-consistency cached --id-label devcontainer.local_folder=\wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node --log-level debug --log-format json --config /home/jbl/redacted/vscode-dev-containers/containers/javascript-node/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true --terminal-columns 197 --terminal-rows 23 [2022-08-24T09:45:05.596Z] Exit code 1 [2022-08-24T09:45:05.604Z] Command failed: /home/jbl/.vscode-server/bin/e4503b30fc78200f846c62cf8091b76ff5547662/node /home/jbl/.vscode-remote-containers/dist/dev-containers-cli-0.245.2/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/jbl/redacted/vscode-dev-containers/containers/javascript-node --workspace-mount-consistency cached --id-label devcontainer.local_folder=\wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node --log-level debug --log-format json --config /home/jbl/redacted/vscode-dev-containers/containers/javascript-node/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true --terminal-columns 197 --terminal-rows 23 [2022-08-24T09:45:05.604Z] Exit code 1 [2022-08-24T09:45:12.871Z] Start: Run: wsl -d Ubuntu -e wslpath -u \wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node [2022-08-24T09:45:13.061Z] Stop (190 ms): Run: wsl -d Ubuntu -e wslpath -u \wsl$\Ubuntu\home\jbl\redacted\vscode-dev-containers\containers\javascript-node

jacobbonde avatar Aug 24 '22 09:08 jacobbonde

I had Docker Desktop installed previously, but it was uninstalled before installing Rancher Desktop - if that is helpful to know.

jacobbonde avatar Aug 24 '22 09:08 jacobbonde

When the workspace is in WSL, VSCode runs docker in WSL. And what I just found is that -v works reliably, but --mount does not. For normal directories, --mount works most of the time, but sometimes mounts an empty directory with 700 permissions.

Probably the same root cause as #2780.

jan-hudec avatar Sep 06 '22 08:09 jan-hudec

I have the same issue with Rancher Desktop 1.7.0

Yuyan-Li avatar Feb 23 '23 16:02 Yuyan-Li

I fixed it by running

sudo chown root:docker /var/run/docker.sock
sudo chmod g+w /var/run/docker.sock

Taken from https://github.com/rancher-sandbox/rancher-desktop/issues/1156#issuecomment-1017042882

Yuyan-Li avatar Feb 24 '23 11:02 Yuyan-Li