Search code examples
dockernfsdocker-volume

Receive "connection refused" when I try to run a Docker Container with NFS Volume


I'm working with NFS Volume. I created a NFS server and on my rasberry pi I set the client and if I mount the directory exposed I can see the content, It's mean that the configuration works.

My goal is to create a volume with the following command:

 sudo docker volume create --driver local \
    --opt type=nfs \
    --opt o=addr=10.0.0.5,rw \
    --opt device=:/export/users/reddata \
    foo

As I saw in the documentation the create a NFS volume. My problem is the follow, when I run the container:

sudo docker run -it -p 1880:1880 -v foo:/data --name mynodered -d nodered/node-red

I receive the following error:

docker: Error response from daemon: failed to mount local volume: mount :/export/users/reddata:/var/lib/docker/volumes/foo/_data, data: addr=10.0.0.5: connection refused.
See 'docker run --help'.

I this that something it's not authorized, but I also think that I can mount my shared directory on my pi the configuration previous did should works.

Do you have any idea?

Thanks for your time

Alessandro


Solution

  • I solved the problem. The problem was the way to create the volume, the right way is:

    sudo docker volume create --driver local \
    --opt type=nfs \
    --opt o=addr=10.0.0.5,nfsvers=4 \
    --opt device=:/export/users/reddata \
    foo
    

    It's necessary to specify the nfsvers=4.

    Another important configuration, in my case it's not necessary to supervise the host that access my folder, in the server my /etc/exports it the follow:

    export/users/reddata *(rw,sync,no_subtree_check,insecure)

    With the *, I specify all IPs on the network.

    Best Regards

    Alessandro