NFS, docker-compose, "failed to mount local volume:…"

Hello,

I’m asking the Docker community for help because I’m facing a problem.

I execute a docker-compose which launches a docker swarm stack, I want to mount an NFS volume but I get an error message.

Error message >> “failed to mount local volume:…”

Can you help me ?
Is my configuration correct ?
I can map the network share and write to it from ubuntu.

docker-compose.yml

Volumes

volumes:
  postgresql_data:
    driver_opts:
      type: "nfs"
      o: "addr=172.20.2.10,nfsvers=4"
      device: ":/postgresql_data"

docker volume inspect

### docker volume inspect
root@xxxxxx:/opt/Alfresco# docker volume inspect Alfresco_postgresql_data
[
    {
        "CreatedAt": "2023-10-14T09:53:19Z",
        "Driver": "local",
        "Labels": {
            "com.docker.stack.namespace": "Alfresco"
        },
        "Mountpoint": "/var/lib/docker/volumes/Alfresco_postgresql_data/_data",
        "Name": "Alfresco_postgresql_data",
        "Options": {
            "device": ":/postgresql_data",
            "o": "addr=172.20.2.10,nfsvers=4",
            "type": "nfs"
        },
        "Scope": "local"
    }
]

I’ve just tested this configuration and it doesn’t work either, but I have another error :

Error message >> failed to copy file info for …

Do you have any ideas ?
Thanks you

docker-compose.yml

### Volumes 

volumes:
  postgresql_data:
    driver: local
    driver_opts:
      type: "nfs"
      o: "addr=172.20.2.10,rw"
      device: ":/postgresql_data"

Please format your posts according How to format your forum posts

Please also share full error messages, so we can see their origin and understand the context.

Hello Meyay,

Thanks for your feedback, this is my second post so please bear with me :slight_smile:

How can I get the full error message?
It’s not displayed in full.
Is it possible to see it somewhere in the logs?

Thanks for your feedback.

Assuming your nfs server has the ip 172.20.2.10, the installed nfs server serves version 4 and you exported the folder /postgresq_data, and your docker host ip is allowed to access the export, then it should be correct.

The output of volume inspect is as expected.

You need to make sure the unix file permissions are alligned between the shared remote folder and the uid:gid of the container process. So if your nfs share is owned by uid xxxx, but the container runs as uid yyyy, then the container won’t be able to access the share.

Please share following outputs

  • from the nfs server:
ls -lan /postgresq_data
ip addr show scope global
cat /etc/exports
  • from the docker host:
ip addr show scope global

Thank you for your prompt reply.

Context:
The server IP address is indeed 172.20.2.10, it’s a Windows Server 2022 with the NFS role.
I’ve opened all accesses, and the same goes for the firewall.

Information:
Information that may be important: server 172.20.2.10 is the domain controller and the Ubuntu 22.04 server with IP address 172.20.2.46 is a member of this domain.

Question:
How can I align permissions between the container and the remote folder?
How do I know it’s NFS version 4 installed on Windows Server 2022? >> Installer et configurer un serveur et un client NFS sous Windows Server 2016 - Windows Server - Tutoriels - InformatiWeb Pro

Suggestion:
Is there a workaround?

This is the first time I’ve used NFS on Windows Server 2022.

Thank you very much for your help.

ip a

### from the docker host:

3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:11:6f:d2 brd ff:ff:ff:ff:ff:ff
    altname enp2s4
    inet 172.20.2.46/16 brd 172.20.255.255 scope global ens36
       valid_lft forever preferred_lft forever


**ipconfig /all**

```yaml
### from the nfs server:

Carte Ethernet Ethernet0 :

   Suffixe DNS propre à la connexion. . . :
   Description. . . . . . . . . . . . . . : Intel(R) 82574L Gigabit Network Connection
   Adresse physique . . . . . . . . . . . : 00-0C-29-1A-F0-7A
   DHCP activé. . . . . . . . . . . . . . : Non
   Configuration automatique activée. . . : Oui
   Adresse IPv4. . . . . . . . . . . . . .: 172.20.2.10(préféré)
   Masque de sous-réseau. . . . . . . . . : 255.255.0.0
   Passerelle par défaut. . . . . . . . . :
   Serveurs DNS. . .  . . . . . . . . . . : 172.20.2.10
                                       1.1.1.1
   NetBIOS sur Tcpip. . . . . . . . . . . : Activé

### Get-WindowsFeature


[X] Services de fichiers et de stockage                 FileAndStorage-Services        Installed
    [X] Services de fichiers et iSCSI                   File-Services                  Installed
        [X] Serveur de fichiers                         FS-FileServer                  Installed
        [ ] BranchCache pour fichiers réseau            FS-BranchCache                 Available
        [ ] Déduplication des données                   FS-Data-Deduplication          Available
        [ ] Dossiers de travail                         FS-SyncShareService            Available
        [ ] Espaces de noms DFS                         FS-DFS-Namespace               Available
        [ ] Fournisseur de stockage cible iSCSI (fou... iSCSITarget-VSS-VDS            Available
        [X] Gestionnaire de ressources du serveur de... FS-Resource-Manager            Installed
        [ ] Réplication DFS                             FS-DFS-Replication             Available
        [ ] Serveur cible iSCSI                         FS-iSCSITarget-Server          Available
        [X] Serveur pour NFS                            FS-NFS-Service                 Installed
        [ ] Service Agent VSS du serveur de fichiers    FS-VSS-Agent                   Available

I won’t be able to help with Windows Server - I didn’t touch it the last 10 years :slight_smile:

I will leave this one for someone else to answer.

1 Like

Meyay,

Thank you very much for your help.