0

使用 vscode 和 wsl2,我尝试使用默认方法启动容器并且没有自定义。这产生了与下面相同的错误。

所以按照 vscode 文档,我"workspaceMount"在 devcontainer.json 中设置了一个

"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/myRepo,type=bind,consistency=delegated",
"workspaceFolder": "/workspaces",

我选择Reopen in container,启动顺序发生但产生错误

a mount config is invalid, make sure it has the right format and a source folder that exists on the machine where the Docker daemon is running

日志错误是

Command failed: docker run -a STDOUT -a STDERR --mount source=d:\git\myRepo,target=/workspaces/myRepo,type=bind,consistency=delegated --mount type=volume,src=vscode,dst=/vscode -l vsch.quality=stable -l vsch.remote.devPort=0 -l vsch.local.folder=d:\git\myRepo --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --entrypoint /bin/sh vsc-myRepo-a878aa9edbcf04f717c76e764dabcde6 -c echo Container started ; trap "exit 0" 15; while sleep 1 & wait $!; do :; done

通过从 docker 桌面启动容器,我可以确认

cd /workspaces
ls -l 
drwxr-xr-x 2 root root 4096 Dec  3 11:48 myRepo

这个问题是楼主的问题root:root吗?

这应该由 chown 在 Dockerfile 中更改吗?如果是这样,你能提供一个示例代码来做到这一点,是RUN chown ...吗?

4

1 回答 1

0

我猜你遵循了https://code.visualstudio.com/docs/remote/containers-advanced中的文档

源应包含子文件夹“myRepo”和目标仅“工作区”

"workspaceMount": "source=${localWorkspaceFolder}/myRepo,target=/workspaces,type=bind,consistency=delegated",
"workspaceFolder": "/workspaces",
于 2020-12-17T12:24:16.103 回答