首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从WSL容器中访问\\WSL$\ within container \some\file?

如何从WSL容器中访问\\WSL$\ within container \some\file?
EN

Stack Overflow用户
提问于 2021-06-09 16:48:57
回答 1查看 54关注 0票数 0

在Windows中,我可以从\\wsl$下访问所有WSL容器的文件系统。

从WSL容器内部,我可以作为/mnt/c访问windows C:\驱动器。

但是如何从WSL容器内部访问另一个容器的驱动器呢?

我正在尝试从WSL容器中访问\\wsl$\othercontainer\some\file

wslpath通常可以将Windows文件路径转换为可从WSL访问的路径:

代码语言:javascript
复制
WSL2@~» wslpath 'C:\Windows\System32\drivers\etc\hosts'
/mnt/c/Windows/System32/drivers/etc/hosts

但它不适用于:

代码语言:javascript
复制
WSL2@~» wslpath '\\wsl$\othercontainer\some\file'
wslpath: \\wsl$\othercontainer\some\file

WSL2@~» echo $?
1

当然还有:

代码语言:javascript
复制
WSL2@~» ls -l '\\wsl$\othercontainer\some\file'
ls: cannot access '\\wsl$\othercontainer\some\file': No such file or directory
EN

回答 1

Stack Overflow用户

发布于 2021-06-11 03:56:03

This answer给出了答案:

代码语言:javascript
复制
sudo mkdir /mnt/othercontainer
sudo mount -t drvfs '\\wsl$\othercontainer' /mnt/othercontainer
ls -l /mnt/othercontainer/some/file

注释:看起来不支持符号链接。当遇到一个错误时,我们会得到如下错误:

代码语言:javascript
复制
$ ls -l /mnt/othercontainer/bin

ls: cannot read symbolic link '/mnt/othercontainer/bin': Function not implemented
lrwxrwxrwx 1 root root 7 Apr 23  2020 /mnt/othercontainer/bin
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67900684

复制
相关文章

相似问题

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