NFS Native Support

This is the error I get:

ERROR: for plain-docker-nfsmount_api_1  UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

ERROR: for api  UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).

I think itā€™s related to the image I use (which is devwithlando/php:7.1-apache). This is my docker-compose.yml:

version: '2'
services:
  api:
    image: devwithlando/php:7.1-apache
    volumes:
      - "nfsmount:/app"

volumes:
  nfsmount:
    driver: local
    driver_opts:
      type: nfs
      o: addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3
      device: ":/Users/manuele/Work/Projects/plain-docker-nfsmount"

@trajano Iā€™ll try your plugin thank you!

1 Like

@seanhandley - thanks for this working sample!

Does anyone have a reference to any documentation about this?
Except for the laconic release note ā€œSupport NFS Volume sharingā€ itā€™s as if this doesnā€™t exist.

Not to my knowledge :frowning: But itā€™s been a while since I tried to find any docs.

were you able to test successfully?

It may be the same issue we have in Windows where there is a race condition of the share drive not connected yet before the containers start up.

Could you explain this a bit more? Iā€™m having an issue like this with the NFS native support on Mac. I need the shared directory (the root of the docker4drupal repo, which has docker-compose.yml and such) to be shared with a php container and an nginx container. But the php container never comes up, which takes down the nginx container with it.

Iā€™m not sure what NFS options would be needed for a php-fpm based container and an nginx container to share the same NFS share. But this does not appear to work:

$ docker volume inspect d8_d8-nfs
[
    {
        "CreatedAt": "2018-08-07T01:01:32Z",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "d8",
            "com.docker.compose.version": "1.22.0",
            "com.docker.compose.volume": "d8-nfs"
        },
        "Mountpoint": "/var/lib/docker/volumes/d8_d8-nfs/_data",
        "Name": "d8_d8-nfs",
        "Options": {
            "device": ":/Users/myacct/sites/d8",
            "o": "addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3",
            "type": "nfs"
        },
        "Scope": "local"
    }
]

@seanhandley - I remember I saw you comment something about nfsv4, not sure whereā€¦

Any chance you remember how you managed to get it working with nfsv4?
When I try I get this error: ā€œprotocol not supportedā€ when using ā€˜nfsvers=4ā€™, ā€˜nfsvers=4.1ā€™ and ā€˜vers=4ā€™

Also, do you remember what seemed more stable with nfsv3? Iā€™m actually trying to move to v4 to see if it improves performance, mainly around deleting many files and also how nfsv3 implements the ā€œsilly renameā€ (causing ā€œā€Device or resource busyā€ errors on random .nfsXXXXXā€™ files)

@talyag Iā€™m not sure about running v4 but hereā€™s the options Iā€™m using:

addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3,acregmin=1,acdirmin=1

This works fine for a Rails app running locally.

ok, tks for sharing!
I will play around with the acregmin and acdirmin attributes, those might actually solve some (rare) cases where users have seen stale files.

In general, this solution has been running fine for us for a while now (developing jvm projects with bazel, where bazel is run inside a container)

When I try to bring up my containers, docker-compose is telling me:

ERROR: for docker_php_1 Cannot start service php: error while mounting volume ā€˜/var/lib/docker/volumes/docker_wordpress/_dataā€™: error while mounting volume with options: type=ā€™nfsā€™ device=ā€™:/Volumes/Drobo/src/megbitton_com/docker/wordpressā€™ o=ā€™addr=localhost,rwā€™: operation not supported

However, I can execute

docker volume create ā€” driver local ā€” opt type=nfs ā€” opt o=addr=localhost,rw ā€” opt device=/Volumes/Drobo/src/megbitton_com/docker/wordpress wordpress

without issue, and an inspection of that volume shows

    [
     {
     ā€œCreatedAtā€: ā€œ2018ā€“10ā€“30T15:32:41Zā€,
     ā€œDriverā€: ā€œlocalā€,
     ā€œLabelsā€: {},
     ā€œMountpointā€: ā€œ/var/lib/docker/volumes/wordpress/_dataā€,
     ā€œNameā€: ā€œwordpressā€,
     ā€œOptionsā€: {
     ā€œdeviceā€: ā€œ/Volumes/Drobo/src/megbitton_com/docker/wordpressā€,
     ā€œoā€: ā€œaddr=localhost,rwā€,
     ā€œtypeā€: ā€œnfsā€
     },
     ā€œScopeā€: ā€œlocalā€
     }
    ]

Furthermore, I can mount that NFS share locally on my Mac using either sudo mount from the command line or using the Finderā€™s Connect to Server dialog. Any ideas what might be missing? Iā€™m defining the volume in my compose file as such

    volumes:
     wordpress:
     driver: local
     driver_opts:
     device: ā€œ:/Volumes/Drobo/src/megbitton_com/docker/wordpressā€
     o: addr=localhost,rw
     type: nfs

    and for the service

    volumes:
     ā€” wordpress:/code

Any insights would be appreciated. Thanks!

I fixed it. I changed ā€œlocalhostā€ to the fqdn for my machine, and now it works.

Iā€™m creating the volume like this

channelArtifacts:
    driver: local
    driver_opts:
      type: "nfs"
      o: "addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=4"
      device: ":../nfs/channelArtifacts"

in file compose-orderer.yaml and start the file like

docker stack up network -c ./docker-compose-files/compose-orderer.yaml

then I mount the volume in some other container in another file compose-peer.yaml

network_channelArtifacts:/etc/hyperledger/fabric/cbau/msp

When I run the file using the given below command it gives error.

docker stack up network -c ./docker-compose-files/compose-peer.yaml

Error

service peer: undefined volume "network_channelArtifacts"

Hi @seanhandley,

Thanks for your info here, I am still facing this issue (Permission denied), I have copy pasted everything as you have mentioned in this page, Yet I am facing the permission issue, When I executed ā€œshowmount -eā€ I am getting empty results ( It just says "Exports list on localhost: " ).

My docker-compose file as follows

volumes:
  nfsmount:
  driver: local
    driver_opts:
     type: nfs
     o: addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3
  device: ":${PWD}"

And I am getting below error:

failed to mount local volume: mount :/Users/santhu/docker:/var/lib/docker/volumes/docker_nfsmount/_data, data: addr=192.168.65.2,nolock,hard,nointr,nfsvers=3: permission denied

when I do cat /etc/exports file : I can see below info

/Users -alldirs -mapall=502:20 localhost

Not sure what the problem is, But I am struggling with this error from past one week, Would you mind suggesting what went wrong here? Thanks in advance.

Hi @santhus

Iā€™m sorry youā€™re still having trouble.

Unfortunately the nature of my job has changed and Iā€™m not working with docker config issues any more. Iā€™d like to tell you I could commit to helping fix this in my spare time but Iā€™m at home in lockdown with my family and ā€œspare timeā€ is an alien concept right now!

Hope you can figure it out, or get some help from someone else on the forum.

Best of luck,
Sean

Thanks for replying me, Stay safe @seanhandley