我使用的是VSCode devcontainers,你如何在devcontainers.json中有一个与windows和MAC兼容的挂载部分?访问"mounts"部分下的source=...部分时出现问题。
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.106.0/containers/python-3
{
"name": "Python 3",
"context": "..",
"dockerFile": "Dockerfile",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "venv/bin/pylint",
},
// Change <username> to user path (Ex. /Users/vfrank/ on a MAC)
"mounts": [
"source=<full home path>/.aws/credentials,target=/home/vscode/.aws/credentials,type=bind,consistency=cached"
],
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "echo 'done'",
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}可在MAC上运行,但不能在Windows上运行
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.aws/credentials,target=/home/vscode/.aws/credentials,type=bind,consistency=cached"
]可在windows上运行,但不能在MAC上运行
"mounts": [
"source=~/.aws/credentials,target=/home/vscode/.aws/credentials,type=bind,consistency=cached"
]我在Windows上有docker文件共享设置,在MAC上有/Users,但我在使用devcontainers时得到的错误是文件夹或文件不存在。我可以让它在两台计算机上工作,这样它就不会与文件权限或从docker访问相关。
我正在寻找一个单一的source=...命令,可以在视窗(10+)和MAC上工作。
发布于 2021-06-02 18:20:32
如果您这样做:
"source=${localEnv:HOME}${localEnv:USERPROFILE}\\.aws\\credentials,target=/root/.aws/credentials,type=bind,consistency=cached"那么在每个平台上只有一个扩展是非空的,你会得到你想要的结果。
https://stackoverflow.com/questions/66174072
复制相似问题