首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VSCode DevContainers:如何在MAC和Windows上挂载主文件

VSCode DevContainers:如何在MAC和Windows上挂载主文件
EN

Stack Overflow用户
提问于 2021-02-12 22:59:44
回答 1查看 514关注 0票数 3

我使用的是VSCode devcontainers,你如何在devcontainers.json中有一个与windows和MAC兼容的挂载部分?访问"mounts"部分下的source=...部分时出现问题。

代码语言:javascript
复制
// 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上运行

代码语言:javascript
复制
    "mounts": [
        "source=${localEnv:HOME}${localEnv:USERPROFILE}/.aws/credentials,target=/home/vscode/.aws/credentials,type=bind,consistency=cached"
    ]

可在windows上运行,但不能在MAC上运行

代码语言:javascript
复制
    "mounts": [
        "source=~/.aws/credentials,target=/home/vscode/.aws/credentials,type=bind,consistency=cached"
    ]

我在Windows上有docker文件共享设置,在MAC上有/Users,但我在使用devcontainers时得到的错误是文件夹或文件不存在。我可以让它在两台计算机上工作,这样它就不会与文件权限或从docker访问相关。

我正在寻找一个单一的source=...命令,可以在视窗(10+)和MAC上工作。

EN

回答 1

Stack Overflow用户

发布于 2021-06-02 18:20:32

如果您这样做:

代码语言:javascript
复制
"source=${localEnv:HOME}${localEnv:USERPROFILE}\\.aws\\credentials,target=/root/.aws/credentials,type=bind,consistency=cached"

那么在每个平台上只有一个扩展是非空的,你会得到你想要的结果。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66174072

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档