How to mount NFS to windows docker container?

Hi All, I am not able to see file sharing tab in settings anymore for docker desktop. I want to mount NFS folder to windows docker container. I am using below command:

docker run -v "$HOME\foo:C:\Users\ContainerAdministrator\foo" --mount type=volume,dst=M:\,volume-opt=type=nfs,volume-opt=device=:FileSystem-D,volume-opt=o=addr= -p 80:80 -p 81:81 -p 443:443 -p 8080:8080 -p 8081:8081 -p 4848:4848 -it --entrypoint="docker-entrypoint.bat" docker/win2019 cmd

So, for the mount the above uses:

--mount type=volume,dst=M:\,volume-opt=type=nfs,volume-opt=device=:FileSystem-D,volume-opt=o=addr=

getting this error: options are not supported on this platform.

Appreciate urgent help…


Asides, not answering your main question: for the CIFS/NFS shares I used from a Windows Docker Desktop running Linux containers, the file sharing page was not involved to grant access. Also, once I somehow had broken things, I could remove erroneous lines from some AppData\Roaming\Docker\settings.json.

Mounting NFS share on a linux container shouldn’t be a problem. Can be done using -v option… but the same option don’t work for windows containers.

1 Like

I know this is a bit old, but it is unresolved & suggests inaccurate information.

I am currently trying to mount an NFS share onto my Windows Docker Desktop running under WSL2. I am trying to mount to a Linux container not a Windows container. my mount point is an Asustor NAS with NFS enabled, & NF permissions added to the share folder with all IPs allowed.

I have been trying for some time to get this to work & have tried many options. I finally made a realization that, hopefully, will help me resolve this.

  • WSL2 does NOT use the local LAN IP, instead it creates a virtual one with a different LAN IP address. So trying to connect over the home network, I now believe, is not going to work at all.
  • No matter what I do it always tells me that the directory does not exist. I initially thought I was doing something wrong, but after every alteration I could think to try, including many that I have found in various places online that seem to work fine for others, I have not been able to make it work.

Unless someone can show a way that actually works on a machine running Docker Desktop in WSL2 (The standard Windows Docker Desktop configuration) I believe doing so is not possible without modifying the system like what people do to make their WSL a local IP on their local network subnet

Right after my post I ended up looking at another issue (I found this while searching for an answer after all) & actually found a solution. I was going to edit the previous message but as it’s still being reviewed before being posted I cannot but don’t want to forget.

You CAN mount an NFS volume in WSL2 Windows Docker
But it requires a step in WSL2 Host Linux OS (Ubuntu in my case)
You need to install the NFS-common service in the Linux host
for Ubuntu it was pretty simple

sudo apt update
sudo apt install nfs-common

Once that’s done the standard Linux commands or docker-compose commands through Portainer in my case, work correctly.