Docker Community Forums

Share and learn in the Docker community.

The correct way to create an NFS volume

I am using docker on Debian Buster and want to create an NFS volume which will use an NFS share on my NAS. So I tried this command:

docker volume create --driver local \
  --opt type=nfs \
  --opt o=addr=192.168.1.29,rw \
  --opt device=:/volumes \
  nginx

But this creates a directory under the default path /var/lib/docker/volumes instead of creating the “nginx” directory under \192.168.1.29\volumes\nginx

What I’m I doing wrong here?

What is wrong is not what you do, but what you expect :slight_smile:

Why would creating a handle for a remote nfs share create a folder in the nfs share?

You need to create the nginx subfolder on your nas’s nfs export first.
Then provide the full path after the exported share when creating the volume:

docker volume create --driver local \
  --opt type=nfs \
  --opt o=addr=192.168.1.29,rw \
  --opt device=:/volumes/nginx \
  nginx

There is no way to update an existing volume, you will need to delete it first.

1 Like

thanks for the help, it worked great.