重写VSCode远程容器会话中的UID GID



我在Windows 10机器上运行VSCode,连接到远程Linux主机上的Docker实例,以开发C++项目。docker实例装载源代码文件的本地文件夹,并将用户设置为与Linux主机上的用户匹配,以避免文件所有权和权限问题。

在Windows 10上,我使用WSL1,默认用户同时具有UID/GID 1000,VSCode的docker进程使用这些ID启动并连接到远程的docker实例。有没有一种方法可以覆盖VSCode使用的UID/GID,使其与远程上的ID匹配?

谢谢,

Step 1/4 : FROM devenv:latest
---> 120d987bae07
Step 2/4 : RUN groupadd -g 301765 chengd
---> Using cache
---> 58a697ed3565
Step 3/4 : RUN useradd -l -u 301765 -g chengd chengd
---> Using cache
---> b5c7c2b48a83
Step 4/4 : USER chengd
---> Using cache
---> f310c9d1e05b
Successfully built f310c9d1e05b
Successfully tagged vsc-devenv-9da1a5f5cedc16a80d314a148acdbcaf:latest
[7325 ms] Start: Run: wsl -d Ubuntu-20.04 -e /bin/sh -c cd '/home/da/repos/devenv' && DISPLAY='1' ELECTRON_RUN_AS_NODE='1' SSH_ASKPASS='d:UsersChengD.vscodeextensionsms-vscode-remote.remote-containers-0.177.2scriptsssh-askpass.bat' VSCODE_SSH_ASKPASS_NODE='D:UsersChengDAppDataLocalProgramsMicrosoft VS CodeCode.exe' VSCODE_SSH_ASKPASS_MAIN='d:UsersChengD.vscodeextensionsms-vscode-remote.remote-containers-0.177.2distcommonsshAskpass.js' VSCODE_SSH_ASKPASS_HANDLE='\.pipessh-askpass-7e8e4f69496930d0e88509584ba46ab3357d9ff1-sock' DOCKER_CONTEXT='tcp_201' VSCODE_SSH_ASKPASS_COUNTER='5' docker 'inspect' '--type' 'image' 'vsc-devenv-9da1a5f5cedc16a80d314a148acdbcaf'
[10240 ms] Start: Run: wsl -d Ubuntu-20.04 -e /bin/sh -c cd '/home/da/repos/devenv' && DISPLAY='1' ELECTRON_RUN_AS_NODE='1' SSH_ASKPASS='d:UsersChengD.vscodeextensionsms-vscode-remote.remote-containers-0.177.2scriptsssh-askpass.bat' VSCODE_SSH_ASKPASS_NODE='D:UsersChengDAppDataLocalProgramsMicrosoft VS CodeCode.exe' VSCODE_SSH_ASKPASS_MAIN='d:UsersChengD.vscodeextensionsms-vscode-remote.remote-containers-0.177.2distcommonsshAskpass.js' VSCODE_SSH_ASKPASS_HANDLE='\.pipessh-askpass-7e8e4f69496930d0e88509584ba46ab3357d9ff1-sock' DOCKER_CONTEXT='tcp_201' VSCODE_SSH_ASKPASS_COUNTER='6' docker 'build' '-f' '/tmp/vsch/updateUID.Dockerfile-0.177.2' '-t' 'vsc-devenv-9da1a5f5cedc16a80d314a148acdbcaf-uid' '--build-arg' 'BASE_IMAGE=vsc-devenv-9da1a5f5cedc16a80d314a148acdbcaf' '--build-arg' 'REMOTE_USER=chengd' '--build-arg' 'NEW_UID=1000' '--build-arg' 'NEW_GID=1000' '--build-arg' 'IMAGE_USER=chengd' '/tmp/vsch'

通过在devcontainer.json.中将updateRemoteUserUID设置为false解决了问题

相关内容

  • 没有找到相关文章

最新更新