microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.67k stars 290 forks source link

Invalid mount configuration used when connecting from Windows to Docker on remote Linux host #3680

Closed ghost closed 4 years ago

ghost commented 4 years ago

This seems related to #531 but the failure mode is different.

Summary

I am unable to get a local workspace mounted in a container running on a remote host.

Does this issue occur when you try this locally? No Does this issue occur with extensions disabled? All extensions but those from the Remote Development pack are disabled

Configuration

Configuration details Host machine Version: 1.49.0 (system setup) Commit: e790b931385d72cf5669fcefc51cdf65990efa5d Date: 2020-09-10T13:22:08.892Z Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.18363 Remote machine Linux version Distributor ID: Ubuntu Description: Ubuntu 16.04.6 LTS Release: 16.04 Codename: xenial Docker version Client: Docker Engine - Community Version: 19.03.12 API version: 1.40 Go version: go1.13.10 Git commit: 48a66213fe Built: Mon Jun 22 15:45:49 2020 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.12 API version: 1.40 (minimum version 1.12) Go version: go1.13.10 Git commit: 48a66213fe Built: Mon Jun 22 15:44:20 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.13 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683

Prereqs

  1. SSH key-based authentication set up and working to access remote host.
  2. Proper SSH credentials set up with SSH Agent.

Repro steps

  1. Clone the vscode-remote-try-python repo

    git clone https://github.com/Microsoft/vscode-remote-try-python
  2. Open VS Code in the created directory

  3. Install VS Code Remote extension pack

  4. Install Docker extension

  5. Set new DOCKER_HOST in .vscode/settings.json

    {
        "docker.host": "ssh://user@host"
    }
  6. Confirm Docker connectivity via Docker extension sidebar

  7. Press F1 and select `Remote-Containers: Reopen in Container..."

Expected results

VS Code window open with workspace visible and able to run/debug on container running on remote host.

Actual results

Console log [28 ms] Start: Resolving remote [30 ms] Setting up container for folder or workspace: c:\Users\xxx\Desktop\tmp\vscode-bug-repro [31 ms] Start: Check Docker is running [32 ms] Start: Run: docker info [1495 ms] Start: Run: git rev-parse --show-toplevel [1576 ms] Start: Run: docker ps -q -a --filter label=vsch.local.folder=c:\Users\xxx\Desktop\tmp\vscode-bug-repro --filter label=vsch.quality=stable [2282 ms] Start: Run: docker build -f c:\Users\xxx\Desktop\tmp\vscode-bug-repro\.devcontainer\Dockerfile -t vsc-vscode-bug-repro-ceab74e1dce3121641b09cb3e2fca652 --build-arg VARIANT=3 c:\Users\xxx\Desktop\tmp\vscode-bug-repro Sending build context to Docker daemon 128.5kB Step 1/6 : ARG VARIANT="3" Step 2/6 : FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} 0-3: Pulling from vscode/devcontainers/python 57df1a1f1ad8: Pull complete 71e126169501: Pull complete 1af28a55c3f3: Pull complete 03f1c9932170: Pull complete 65b3db15f518: Pull complete 3e3b8947ed83: Pull complete a4850b8bdbb7: Pull complete 416533994968: Pull complete 1b580f9ce4ce: Pull complete 492a5e8971b9: Pull complete 4d79fbddf622: Pull complete 16c0352158c2: Pull complete c91f83778d9c: Pull complete a5e027586e68: Pull complete 3eefc798d9e3: Pull complete Digest: sha256:fcacc51c12d1fda2f72aa4c9453aa83c6f8701a461b6609d0dd126aa7d214b81 Status: Downloaded newer image for mcr.microsoft.com/vscode/devcontainers/python:0-3 ---> 0915e9c9171c Step 3/6 : ENV PIP_TARGET=/usr/local/pip-global ---> Running in b946fad559a8 Removing intermediate container b946fad559a8 ---> 59b823c9a772 Step 4/6 : ENV PYTHONPATH=${PIP_TARGET}:${PYTHONPATH} ---> Running in fd6172253c33 Removing intermediate container fd6172253c33 ---> dd00720a12a9 Step 5/6 : ENV PATH=${PIP_TARGET}/bin:${PATH} ---> Running in 2bfbd1b79b71 Removing intermediate container 2bfbd1b79b71 ---> 480b34483912 Step 6/6 : RUN mkdir -p ${PIP_TARGET} && chown vscode:root ${PIP_TARGET} && echo "if [ \"\$(stat -c '%U' ${PIP_TARGET})\" != \"vscode\" ]; then chown -R vscode:root ${PIP_TARGET}; fi" | tee -a /root/.bashrc /home/vscode/.bashrc /root/.zshrc >> /home/vscode/.zshrc ---> Running in 6a28de12c7ae Removing intermediate container 6a28de12c7ae ---> 95fa6c6db571 Successfully built 95fa6c6db571 Successfully tagged vsc-vscode-bug-repro-ceab74e1dce3121641b09cb3e2fca652:latest SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories. [41790 ms] Start: Run: docker events --format {{json .}} --filter status=start [41853 ms] Start: Starting container [41854 ms] Start: Run: docker run -a STDOUT -a STDERR --mount type=bind,source=c:/Users/xxx/Desktop/tmp/vscode-bug-repro,target=/workspaces/vscode-bug-repro,consistency=cached -l vsch.quality=stable -l vsch.remote.devPort=0 -l vsch.local.folder=c:\Users\xxx\Desktop\tmp\vscode-bug-repro --entrypoint /bin/sh vsc-vscode-bug-repro-ceab74e1dce3121641b09cb3e2fca652 -c echo Container started ; trap "exit 0" 15; while sleep 1 & wait $!; do :; done docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: 'c:/Users/xxx/Desktop/tmp/vscode-bug-repro' mount path must be absolute. See 'docker run --help'. [42728 ms] Start: Run: docker ps -q -a --filter label=vsch.local.folder=c:\Users\xxx\Desktop\tmp\vscode-bug-repro --filter label=vsch.quality=stable [43593 ms] Command failed: docker run -a STDOUT -a STDERR --mount type=bind,source=c:/Users/xxx/Desktop/tmp/vscode-bug-repro,target=/workspaces/vscode-bug-repro,consistency=cached -l vsch.quality=stable -l vsch.remote.devPort=0 -l vsch.local.folder=c:\Users\xxx\Desktop\tmp\vscode-bug-repro --entrypoint /bin/sh vsc-vscode-bug-repro-ceab74e1dce3121641b09cb3e2fca652 -c echo Container started ; trap "exit 0" 15; while sleep 1 & wait $!; do :; done

Commentary

This seems related to the forward-slash-style path used in the --mount, as discussed in #489 and potentially #509. Given those have been closed and it is difficult for me to find more recent reports of this issue, I think it suggests a problem on my end. However, I believe I'm following instructions per the online documentation correctly, so I'm currently at a loss.

chrmarti commented 4 years ago

It is not possible to mount folders across machines, that is a limitation of Docker. If it was possible (there might be storage drivers enabling that), performance of the mounted folder would likely be an issue because access across the network is generally much slower than local disk access.

You could use F1 > Remote-Containers: Clone Repository in Container Volume... to clone the repository in a volume on the remote machine. (First set docker.host in your user settings.)

ghost commented 4 years ago

Now that I've spent some time getting into the details of this, I've re-read the docs on developing inside a container on a remote docker host and see the restriction that you mention above. I also see more clearly now how this limitation is mentioned in #509.

Is it possible to improve the UX for the set of steps I've given above? I feel like there wasn't a direct path from the error messages I saw to the realization that came from creating this issue, getting your feedback, and re-reading the documentation. Perhaps if docker.host specifies a remote machine, VS Code shouldn't try to auto-mount the local workspace? I think this potential solution is also mentioned in #509. VS Code would hopefully at least stop and alert the user that the operation is not going to succeed and how to work around it (since the solutions are known) rather than letting them end up with a invalid mount config for type "bind" message buried in the console log.

I have since modified devcontainer.json to contain the following and confirmed I can run & debug the Flask application:

"workspaceFolder": "/workspaces/vscode-remote-try-python",
"workspaceMount": "source=/home/${localEnv:USERNAME}/vscode-remote-try-python,target=/workspaces/vscode-remote-try-python,type=bind,consistency=cached",

A couple of questions:

chrmarti commented 4 years ago

There is ${containerWorkspaceFolder} you can use to reduce the duplication in workspaceMount. Variables support in the settings is limited to a few settings keys at the moment and docker.host does not support any.

ghost commented 4 years ago

Thanks for the speedy response. Is there an open issue for support of variable use in docker.host ?

chrmarti commented 4 years ago

I don't see any. I suggest you file a feature request for all settings at https://github.com/microsoft/vscode/issues. (You could also file one specifically for docker.host at https://github.com/microsoft/vscode-docker/issues.)

Keeping this issue for investigating to improve the error message.

chrmarti commented 3 years ago

To verify: