On Windows 10 Insider Preview (prerelease.201207-1443) I have mounted successfully a vhdx file with WSL2.
PS C:\Users> wmic diskdrive list brief
Caption DeviceID Model Partitions Size
..
Microsoft virtuális lemez \\.\PHYSICALDRIVE2 Microsoft virtuális lemez 1 5362882560
PS C:\Users> wsl --mount \\.\PHYSICALDRIVE2 --bare
Inside the Ubuntu 20.20 it looks OK, I could mounted and format (ext4) the virtual disk.
/dev/sde1 4.9G 20M 4.6G 1% /mnt/docker/vol/pg_disk_1
I can use it, read, write without any problem. Performance is good.
Issue: I want to use this disk when I create docker container for application data, it is not visible inside the container.
docker run -d -it --name devtest --mount type=bind,source=/mnt/docker/vol/pg_disk_1/nginx,target=/app nginx:latest
docker inspect shows the volume bind mounted:
"Mounts": [
{
"Type": "bind",
"Source": "/mnt/docker/vol/pg_disk_1/nginx",
"Destination": "/app",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
when I create a file on the host eg. example_host.html
User@Pince:/mnt/docker/vol/pg_disk_1/nginx$ ls -l
total 0
-rw-r--r-- 1 r858 r858 0 Jan 3 11:30 example_host.html
not visible when I check inside the container
root@078e4d7007a8:/app# ls -la
total 8
drwxr-xr-x 2 root root 4096 Jan 3 10:32 .
drwxr-xr-x 1 root root 4096 Jan 3 10:15 ..
root@078e4d7007a8:/app# pwd
/app
and if I create a file here inside the container it will be persistent when recreate the container but not in Linux mounted disk. I found it here:
\\wsl$\docker-desktop\mnt\host\wsl\docker-desktop-bind-mounts\Ubuntu-20.04\...
Question: this is normal and I missed something or it is not ready yet in this stage of the development. And do you know anybody a workaround how to use vhdx mounted disk for docker application data on Windows?
The problem is that /dev/sde1
is created and managed by wsl, so not (easily?) accessible by Windows programs like Docker Desktop.
One workaround is to mount \.\PHYSICALDRIVE2 as drive D:
and mounted as :
docker run -v 'D:\data:/data' ...
This way, you can access it both on Windows and wsl.