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

Method 2 to provide exports fails #13

Closed grasshide closed 5 years ago

grasshide commented 5 years ago

Even if I try to expose "/" it says "is not a container directory". Mounting the same folders via -v .exports:/etc/exports does work.

And btw the Alpine Bug seems to be fixed ;-).

ehough commented 5 years ago

Thanks for the report. Just to make sure I understand, do you mean that using the "environment variable" method of constructing /etc/exports doesn't work?

Would you be able to post the logs from the failed container start? Along with the command (or docker-compose.yml etc.) that you used?

I just tested this invocation:

docker run --rm -e NFS_EXPORT_0="/ *(ro)" --cap-add SYS_ADMIN erichough/nfs-server

and the server started normally (logs).

And btw the Alpine Bug seems to be fixed ;-).

I saw that the bug was fixed and committed, but unfortunately the fix didn't make it yet to a version of nfs-utils in the stable repo. I'm checking regularly for that to change, and once it does Alpine will be the default base image for this project.

The fix is, however, in the edge repo and I've got some preliminary work done on the alpine branch.

grasshide commented 5 years ago

Thanks for the quick reply!

Here is the docker compose part I used:

  nfs:
    image: erichough/nfs-server
    container_name: nfs
    cap_add:
      - SYS_ADMIN
    ports:
      - "2049:2049"
    volumes:
      - /mnt/disk1:/mnt/disk1
    environment:
      - NFS_EXPORT_0='/mnt/disk1        192.168.6.0/24(ro,async,subtree_check,insecure,fsid=11)'
    networks:
      - mynetwork

And the error was: ----> WARNING: skipping NFS_EXPORT_1 environment variable since '/mnt/disk1 is not a container directory, ----> collected 0 valid export(s) from NFSEXPORT* environment variables, ----> ERROR: no valid exports, ----> , ----> building /etc/exports from environment variables

Using only:

Using " as quotation character gives me the error: ----> WARNING: skipping NFS_EXPORT_1 environment variable since "/mnt/disk1 is not a container directory

Good to hear that you are still planning to switch to alpine ;-)

ehough commented 5 years ago

Thank you. I was able to reproduce the error locally. Stand by for a fix..

ehough commented 5 years ago

I did some more testing and found the problem. Turns out that it's not a bug in this image, but instead a quirk in how the docker-compose.yml YAML is parsed.

In short, don't use quotes in the environment variable values. So you can use either

environment:
  - NFS_EXPORT_0=/mnt/disk1        192.168.6.0/24(ro,async,subtree_check,insecure,fsid=11)

or

environment:
  NFS_EXPORT_0: /mnt/disk1        192.168.6.0/24(ro,async,subtree_check,insecure,fsid=11)

Give it a whirl and let us know? Thanks again for the report.

grasshide commented 5 years ago

I can confirm that with an adjusted config it now works like a charm! Thanks for the help.