I have a quite special problem. I want to run a service in windows docker that is on my Ubuntu server. My Ubuntu server is in the same pc as my windows machine. I want that the cache and data is synced. I created a dockerfile and a docker-compose file, but windows does not have native support for reading Linux filesystems. Is there a way to mount the harddrive to wsl and access the data that way.
In summery:
How do I mount a Linux filesystem to a docker container in windows?
You mean both machines are virtual machines or you have two separate boot partition run only Windows or Linux at a time? In case of virtual machines, you could create a samba share on Linux and mount it in the Windows container which I have never done. In case of separate boot partitions I don’t think you can mount the Linux filesystem. You would need something that understand the Linux filesystem, but writing Linux filesystem from Windows would be dangerous even if you know a tool that can read ext4 for example on Windows.
Actually @meyay suggested that WSL2 can read Linux filesystems and you could mount entire disks to a WSL2 distribution. If your Docker Desktop uses the WSL2 backend, you could try to mount the disk to a WSL2 distribution and then mount the mounted folder to the Docker container. I’m not using Windows at this moment, so I’m not sure, but should be able to use the path in WSL to mount into a container like:
-v /mnt/wsl/diskname:/data
or something similar. but that works only if you are using a Linux container.