当 运行 WSL2 后端时,如何在 Docker 中创建绑定安装?

How do you create a bind mount in Docker when running with the WSL2 backend?

我试过了

指向D:\s\elasticsearch但我所有的尝试都没有找到路径。

注意我只安装了 docker,没有安装其他 WSL 发行版。

我也试过检查 /mnt 文件夹中是否有如下内容,但它是空的

$ docker run --privileged --rm -v /:/mnt -it alpine ls -la /mnt/mnt
total 2
drwxr-xr-x    2 root     root          2048 May  6 19:43 .
drwxr-xr-x    1 root     root           260 May 14 17:16 ..

WSL 的挂载点在 /run/desktop/mnt/host/<drivename> 中,因此要挂载 d:/s/elasticsearch 使用

docker run --rm -v /run/desktop/mnt/host/d/s/elasticsearch:/mnt alpine ls /mnt