【问题标题】:Mounting local directory to home directory in container将本地目录挂载到容器中的主目录
【发布时间】:2019-05-15 22:10:14
【问题描述】:

我曾希望在devcontainer.json 中使用"workspaceFolder": "/home/jovyan", 可以解决问题,但在使用现有图像/容器时似乎没有任何作用。以下适用于 macOS,但与主机系统上的用户名相关联,不适用于 Windows。

vscode 是否使用了一些变量来允许将本地目录挂载到容器中的主目录?

"runArgs": [
    "-v",
    "/Users/a_user/project_1:/home/jovyan",
]

编辑:

刚刚注意到How to change default volume mount? 和功能请求https://github.com/microsoft/vscode-remote-release/issues/101。还有https://github.com/microsoft/vscode-remote-release/issues/171

【问题讨论】:

    标签: vscode-remote


    【解决方案1】:

    更新:本地工作区文件夹以${localWorkspaceFolder} (documentation) 的形式提供。

    【讨论】:

    • 容器中的主文件夹是已知的(例如,/home/jovyan'). However, the folder to mount (e.g.,, /Users/a_user/project_1) will vary depending on where code/data is stored on a user's computer and on the OS. The docker run` vscode 生成的命令确实知道要挂载的目录,我想访问将相同的信息挂载到/home/jovyan(或home/jovyan/project_1)而不是/workspace/project_1
    • @christof-marti,在我看来,containerWorkspaceFolder 反映了workspaceFolder(例如在devcontainer.json 中的mount 指令中使用)。现在(或在不久的将来)是否有类似的东西对remoteUser 起作用(即某种containerRemoteUser 将允许根据remoteUser 值进行挂载)。
    • @nvidot 目前没有计划。主要价值是避免重复,例如 ${localWorkspaceFolder} 否则未知。
    猜你喜欢
    • 2020-09-20
    • 1970-01-01
    • 2020-03-08
    • 1970-01-01
    • 2022-10-20
    • 1970-01-01
    • 2016-06-10
    • 1970-01-01
    • 2021-11-29
    相关资源
    最近更新 更多