Hi, So I have a Windows instance of syncthing and then a Docker using WSL. I want to mount a physical USB drive to Docker to use in syncthing. Found many things but not much use and can’t seem to create a symbolic link from windows. Any ideas?
I’m not sure there are many folks on this forum who have a similar setup, plus it’s really a support question for Windows rather than for Syncthing (or even Docker).
However, if you could provide more details…
- Syncthing is running natively on Windows and also in a Docker container?
- Which WSL? (There are two distinct generations that take different approaches for running Linux applications. I’m pretty certain which one it is, but just to confirm.)
- Any other details that might be relevant.
Yes your 100% right maybe more docker if anyting since trying to figure out to mount via Docker. Yes using linuxserver/syncthing for docker. latest wsl2 Maybe Docker forms would be better but decided to give a try here first. Since its not relly a windows thing more docker. Like how to mount a physical device in docker.
So the drive you want to use is already accessible inside the virtual machine?
Did you install/set up the virtual machine and then install Docker in it, or did you use Docker Desktop for Windows?
its not in a vm. Have windows native running docker desktop. The drive shows olny in Windows Explorer but not in docker. So I can’t use for syncthing. So need to mount it somehow in Docker. That’s the issue I am trying to figure out.
Microsoft WSL 2 sits on top of slimmed down Hyper-V, and the last time I checked the guest OS was Ubuntu Linux.
Docker Desktop requires either WSL 2 or the full Hyper-V so that it can run a Linux virtual machine to host Docker Engine because Docker Engine requires a process isolation system called cgroups that is a feature of the Linux kernel.
linuxserver/syncthing container is a mini-Linux system, so Syncthing, the system libraries and all of the other dependencies inside the container are all compiled for Linux.
Even if instead of a Linux container it was a Windows container with Syncthing, it would still be a virtual machine.
From Syncthing’s perspective, your physical drive is on a different computer (because Syncthing is inside a virtual machine), so the storage volume must first be mapped to the container: https://docs.docker.com/storage/volumes/
Thanks @gadget for your help. With the help of ChatGPT and using some brains I figured it out. I read the docs and it was useless. I asked in the Docker community, but I didn’t receive a response. Chatgpt told me old stuff but after some back and forth and loads of testing i got it. I’m not sure if it’s related, but it instructed me to mount the drive in WSL2 using ‘mnt’ and then I should be able to access it. However, it only functioned successfully on WSL and not within Docker.
When using Docker desktop to make a new container from an image, it gives you the option to mount a path. Well, if you choose the drive and path in the container, it mounts it to that path in the container. The same applies to any folder in windows… The only caveat is that if the drives disconnect while it’s running, it needs to be restarted.
Might also have to mount the drive to WSL using the following code in WSL terminal. Only use it if it does not work.
sudo mkdir /mnt/d
sudo mount -t drvfs D: /mnt/d
D referring to the drive, so if you’re using a different letter swap it for the one you’re trying to use.
You have to mount it using the above command. To change the letter from D to another change the D: and the last d to whatever drive letter.