Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker VSCode开发者:如何在MAC和Windows上装载主文件_Docker_Visual Studio Code_Vscode Remote - Fatal编程技术网

Docker VSCode开发者:如何在MAC和Windows上装载主文件

Docker VSCode开发者:如何在MAC和Windows上装载主文件,docker,visual-studio-code,vscode-remote,Docker,Visual Studio Code,Vscode Remote,我使用的是VSCode devcontainers,如何在devcontainers.json中有一个兼容windows和MAC的mount部分?我在访问“mounts”部分下的source=…部分时遇到问题 //有关格式的详细信息,请参阅https://aka.ms/vscode-remote/devcontainer.json 或者此文件的自述文件位于: // https://github.com/microsoft/vscode-dev-containers/tree/v0.106.0/c

我使用的是VSCode devcontainers,如何在devcontainers.json中有一个兼容windows和MAC的mount部分?我在访问
“mounts”
部分下的
source=…
部分时遇到问题

//有关格式的详细信息,请参阅https://aka.ms/vscode-remote/devcontainer.json 或者此文件的自述文件位于:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.106.0/containers/python-3
{
“名称”:“Python 3”,
“上下文”:“…”,
“dockerFile”:“dockerFile”,
//在创建容器时设置*default*特定于容器的settings.json值。
“设置”:{
“terminal.integrated.shell.linux”:“/bin/bash”,
“python.pythonPath”:“/usr/local/bin/python”,
“python.linting.enabled”:true,
“python.linting.pyleintenabled”:true,
“python.linting.pylintPath”:“venv/bin/pylint”,
},
//更改用户路径(例如/Users/vfrank/在MAC上)
“坐骑”:[
source=/.aws/credentials,target=/home/vscode/.aws/credentials,type=bind,consistency=cached
],
//添加创建容器时要安装的扩展的ID。
“扩展”:[
“ms python.python”
],
//使用“forwardPorts”使容器内的端口列表在本地可用。
//“转发端口”:[],
//创建容器后,使用“postCreateCommand”运行命令。
“postCreateCommand”:“echo'done'”,
//取消注释以作为非root用户连接。请参阅https://aka.ms/vscode-remote/containers/non-root.
“remoteUser”:“vscode”
}
适用于MAC,但不适用于Windows

“挂载”:[
source=${localEnv:HOME}${localEnv:USERPROFILE}/.aws/credentials,target=/HOME/vscode/.aws/credentials,type=bind,consistency=cached
]
适用于windows,但不适用于MAC

“挂载”:[
source=~/.aws/credentials,target=/home/vscode/.aws/credentials,type=bind,consistency=cached
]
我已经为Windows上的C驱动器和MAC上的/Users设置了docker文件共享,但使用devcontainers时遇到的错误是该文件夹或文件不存在。我可以使它在两台计算机上都工作,因此它与docker的文件权限或访问无关

我正在寻找一个能在Windows(10+)和MAC上运行的
源=…
命令。

如果您这样做:

"source=${localEnv:HOME}${localEnv:USERPROFILE}\\.aws\\credentials,target=/root/.aws/credentials,type=bind,consistency=cached"

然后每个平台上只有一个扩展是非空的,您将得到您想要的结果。

您的Win示例对我不适用。但是我让它在mac上像这样工作:“source=${localEnv:USERPROFILE}\\\\.aws\\credentials,target=/root/.aws/credentials,type=bind,consistency=cached”。这可以工作,但windows正在解决HOME和USERPROFILE问题,并且失败了