Docker Community Forums

Share and learn in the Docker community.

ERROR :docker compose with NFS mount

Hi ,

I am trying nfs mount voume using compose but getting error.

cmopose file:
version: ‘3.2’
services:
mongodb:
image: mongo:3.6.1
container_name: mongodb
volumes:
- “nfs-docker2:/data/db”
ports:
- 27010:27017
command: mongod
volumes:
nfs-docker2:
driver: local
driver_opts:
type: nfs
o: addr= “111.111.111.111:/data/mongodata”
device: “:/mnt/netcool-mongodata”

/data/mongodata is the path where i would like to store the data in the mount machine.

Error am getting:
Creating volume “mongo_nfs-docker2” with local driver
Creating mongodb … error

ERROR: for mongodb Cannot create container for service mongodb: error resolving passed in nfs address: lookup “40.133.27.228:/data/mongodata”: no such host

ERROR: for mongodb Cannot create container for service mongodb: error resolving passed in nfs address: lookup “40.133.27.228:/data/mongodata”: no such host
ERROR: Encountered errors while bringing up the project.

Can any one kindly help.

When i change it to below YML

version: ‘3.2’
services:
mongodb:
image: mongo:3.6.1
container_name: mongodb
volumes:
- “nfs-docker2:/data/db”
ports:
- 27010:27017
command: mongod
volumes:
nfs-docker2:
driver: local
driver_opts:
type: nfs
o: “addr=4.1.2.2”
device: “:/mnt/netcool-mongodata”

ERROR:

ERROR: for mongodb Cannot create container for service mongodb: error while mounting volume with options: type=‘nfs’ device=’:/mnt/netcool-mongodata’ o=‘addr=4.1.2.2’: permissio n denied

ERROR: for mongodb Cannot create container for service mongodb: error while mounting volume with options: type=‘nfs’ device=’:/mnt/netcool-mongodata’ o=‘addr=4.1.2.2’: permissio n denied

Can any one please suggest on the above error ?

Thanks,
Ahemad

you sould always first try if the nfs mount actualy is working from the host:
mount -t nfs -o nfsvers={your nfs version} 4.1.2.2.:/mnt/netcool-mongodata /{your-mount-path-on-host}

Example for nfs4 and mount into /mtn:
mount -t nfs -o nfsvers=4 4.1.2.2.:/mnt/netcool-mongodata /mnt

Don’t forget to umount /mntwhen the test is finished.

Using nfs3 is NOT recommended!