win10下wls2中docker挂载(-v)路径

最近用win10弄了台nas,鉴于性能过剩的原因,于是开启了wls2玩玩docker。

在研究metabase的安装的时候要外挂载插件目录,发现docker -v挂载命令的写法与linux上的不同。google后发现了答案:

Performance is much higher when files are bind-mounted from the Linux filesystem, rather than remoted from the Windows host. Therefore avoid docker run -v /mnt/c/users:/users (where /mnt/c is mounted from Windows).
Instead, from a Linux shell use a command like docker run -v ~/my-project:/sources where ~ is expanded by the Linux shell to $HOME.

例如:
我的metabase在linux上的挂载方式是:

docker run -v /home/metabase/plugins:/plugins metabase

注:/home/metabase/plugins为本地目录

现在,metabase在win10上的挂载方式是:

docker run -v /mnt/c/users/bing/metabase/plugins:/plugins metabase

注:/mnt/c/users/bing/metabase/plugins为本地目录, 换成正常路径则为:C:\Users\bing\metabase\plugins

参考:

  1. Docker Desktop WSL 2 backend
阅读量: | 柯西君_BingWong | 2021-09-27