admin管理员组文章数量:1122832
I am creating a dev container via devcontainer.json on a Windows 10 Host. Ubuntu 24.04 is my distro of choice and we have cloned the repo to WSL for performance gains.
On our Windows machines our developers created the necessary user level .npmrc files to connect to a private Azure Artifacts feed. I would like to avoid having folks recreate these .npmrc files in their dev containers so I am attempting to mount them like so:
// devcontainer.json
"image": "org/experience-builder:1.13-alpine",
"mounts": [
{
"source": "/mnt/c/Users/MY_WINDOWS_USERNAME/.npmrc",
"target": "/root/.npmrc",
"type": "bind"
}
],
If we hard code MY_WINDOWS_USERNAME to our actual Windows user names this works. However, I would like to set this dynamically so we don't have to modify the devcontainer.json for each user.
I've tried setting an environment variable in initializeCommand as shown below but the variable appears to be blank when attempting to reference it the mounts configuration, causing the container to fail upon startup.
"initializeCommand": "export WINUSERPROFILE=$(wslpath $(pwsh.exe -nop -c '$env:USERPROFILE'))"
It's likely this is occurring because the variable is only available for the duration of the shell command. Once initializeCommand
exits the variable is no longer available.
How can I set a dynamic mount source such that us developers can simply clone the repo and open the folder in vscode without any local file modification?
本文标签: dockerSetting devcontainerjson mount source based on user39s windows profile pathStack Overflow
版权声明:本文标题:docker - Setting devcontainer.json mount source based on user's windows profile path - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301081a1931053.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论