ehough / docker-nfs-server

A lightweight, robust, flexible, and containerized NFS server.
https://hub.docker.com/r/erichough/nfs-server/
GNU General Public License v3.0
672 stars 221 forks source link

"No such file or directory" #12

Closed adrianocr closed 5 years ago

adrianocr commented 5 years ago

The following docker-compose file spins up the container with no issues:

versions: "2"
  nfs-server:
    container_name: nfs-server
    image: erichough/nfs-server
    ports: 
      - '2049:2049'
    volumes:
      - '/MediaDownloads:/nfs'
      - '/home/adriano/Code/nfs-server/exports.txt:/etc/exports:ro'
    cap_add:
      - SYS_ADMIN

But the container fails to run. My exports file is the following:

/MediaDownloads 192.168.1.0/24(rw,all_squash,anonuid=1000,anongid=974)

And here is the docker log:

==================================================================
      SETTING UP
==================================================================
----> /etc/exports is bind-mounted
----> checking for presence of kernel module: nfs
----> checking for presence of kernel module: nfsd
----> setup complete

==================================================================
      STARTING SERVICES
==================================================================
----> mounting rpc_pipefs onto /var/lib/nfs/rpc_pipefs
mount: rpc_pipefs mounted on /var/lib/nfs/rpc_pipefs.
----> mounting nfsd onto /proc/fs/nfsd
mount: nfsd mounted on /proc/fs/nfsd.
----> starting rpcbind
----> exporting filesystems
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/MediaDownloads".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: Failed to stat /MediaDownloads: No such file or directory
exporting 192.168.1.0/24:/MediaDownloads
----> exportfs failed

==================================================================
      TERMINATING ...
==================================================================
----> rpc.svcgssd was not running
----> stopping nfsd
----> rpc.idmapd was not running
----> rpc.statd was not running
----> rpc.mountd was not running
----> un-exporting filesystems
----> killing rpcbind
----> un-mounting nfsd from /proc/fs/nfsd
umount: /proc/fs/nfsd (nfsd) unmounted
----> un-mounting rpc_pipefs from /var/lib/nfs/rpc_pipefs
umount: /var/lib/nfs/rpc_pipefs (rpc_pipefs) unmounted

==================================================================
      TERMINATED
==================================================================

If I ls -l my root directory, you'll see I definitely have a MediaDownloads dir in there...

adriano in / at adriano-server
➜ ls -l
total 60
lrwxrwxrwx   1 root    root       7 Aug 22 04:44 bin -> usr/bin
drwxr-xr-x   1 root    root     422 Sep  9 19:39 boot
-rw-r--r--   1 root    root   18462 Aug 21 12:19 desktopfs-pkgs.txt
drwxr-xr-x  20 root    root    4320 Sep 10 18:34 dev
drwxr-xr-x   1 root    root    3844 Sep 10 18:16 etc
drwxr-xr-x   1 root    root      14 Sep  7 13:06 home
lrwxrwxrwx   1 root    root       7 Aug 22 04:44 lib -> usr/lib
lrwxrwxrwx   1 root    root       7 Aug 22 04:44 lib64 -> usr/lib
drwxr-xr-x   1 root    root       0 Sep  8 23:13 media
drwxrwx---   5 adriano docker  4096 Sep 10 14:58 MediaDownloads
drwxr-xr-x   1 root    root      18 Sep  7 13:16 mnt
drwxr-xr-x   1 root    root      70 Sep 10 17:18 opt
dr-xr-xr-x 251 root    root       0 Sep 10 10:21 proc
drwxr-x---   1 root    root     318 Sep 10 12:21 root
-rw-r--r--   1 root    root    3973 Aug 21 12:13 rootfs-pkgs.txt
drwxr-xr-x  26 root    root     740 Sep 10 15:11 run
lrwxrwxrwx   1 root    root       7 Aug 22 04:44 sbin -> usr/bin
drwxr-xr-x   1 root    root      26 Sep 10 02:34 srv
dr-xr-xr-x  13 root    root       0 Sep 10 10:21 sys
drwxr-xr-x   1 adriano docker     0 Sep 11 00:32 test
drwxrwxrwt  21 root    root     740 Sep 11 00:28 tmp
drwxr-xr-x   1 root    root     128 Sep 10 18:16 usr
drwxr-xr-x   1 root    root     124 Sep 10 14:21 var

If it matters this is Arch Linux, the MediaDownloads dir is a mount of an entire HDD, and the filesystem is ext4.

adrianocr commented 5 years ago

I'm an idiot.

The exports.txt file should reference the mount inside the container, not the one on the host. So /nfs 192.168.1.0/24(rw,all_squash,anonuid=1000,anongid=974) would have been the correct exports.txt entry.

@ehough you may want to reference this in the readme for people who aren't so bright (like me)

ehough commented 5 years ago

Glad you sorted it out! Putting together all the puzzle pieces here can be tricky indeed. I can't possibly count the number of times I've made a similar mistake.

Thanks for the suggestion on the readme; I'll add some clarifications asap.