docker-volume-netshare icon indicating copy to clipboard operation
docker-volume-netshare copied to clipboard

Failed to mount NFS Volume when using Docker-Compose

Open chkelly opened this issue 8 years ago • 4 comments

I was able to use compose to startup my first container with an NFS mount without issue. Here is my compose file:

version: '2'
services:
  deluge:
    image: linuxserver/deluge
    restart: always
    environment:
      - PGID=65534
      - PUID=65534
    volumes:
      - deluge-config:/config
      - deluge-downloads:/downloads
volumes:
  deluge-config:
    driver: local
   deluge-downloads:
    driver: nfs
    driver_opts:
      share: "some-host:/data/path"

I can see the volume..

docker volume ls
DRIVER              VOLUME NAME
local               dockerdeluge_deluge-config
nfs                 dockerdeluge_deluge-downloads

This worked great. So I went to spinup a second container with a couple of NFS volume mappings...

version: '2'
services:
  sonarr:
    image: tuxeh/sonarr:latest
    restart: always
    volumes:
      - sonarr-config:/volumes/config
      - sonarr-completed:/volumes/completed
      - sonarr-media:/volumes/media
volumes:
  sonarr-config:
    driver: local
  sonarr-completed:
    driver: nfs
    driver_opts:
      share: "some-host:/data/path"
  sonarr-media:
    driver: nfs
    driver_opts:
      share: "some-host:/data/path/2"

When I docker-compose up -d on the same docker host:

Creating volume "dockersonarr_sonarr-completed" with nfs driver
Creating volume "dockersonarr_sonarr-media" with nfs driver
Creating dockersonarr_sonarr_1

ERROR: for sonarr  Cannot create container for service sonarr: VolumeDriver.Mount: exit status 32
ERROR: Encountered errors while bringing up the project.

The log just showed it getting mounted and then unmounted.

So the first thing I did was edit /etc/default/docker-volume-netshare and changed DKV_NETSHARE_OPTS="nfs" to DKV_NETSHARE_OPTS="nfs --verbose" and restarted the service.

Interestingly enough, the output of docker volume ls doesnt show our nfs volume anymore (although on the host its still mounted, and deluge is still happily writing to it) so possibly this is a second bug?

time="2016-08-05T10:44:16-04:00" level=debug msg="Entering List: { map[]}"

So I attempted to docker-compose up -d again receiving the same error however this is whats in the logs.

time="2016-08-05T10:48:50-04:00" level=debug msg="Entering Get: {dockersonarr_sonarr-completed map[]}"
time="2016-08-05T10:48:50-04:00" level=debug msg="Host path for dockersonarr_sonarr-completed is at /var/lib/docker-volumes/netshare/nfs/dockersonarr_sonarr-completed"
time="2016-08-05T10:48:50-04:00" level=debug msg="Entering Get: {dockersonarr_sonarr-media map[]}"
time="2016-08-05T10:48:50-04:00" level=debug msg="Entering Mount: {dockersonarr_sonarr-completed map[]}"
time="2016-08-05T10:48:50-04:00" level=info msg="Mounting NFS volume dockersonarr_sonarr-completed: on /var/lib/docker-volumes/netshare/nfs/dockersonarr_sonarr-completed"
time="2016-08-05T10:48:50-04:00" level=debug msg="Mounting with NFSv4 - src: dockersonarr_sonarr-completed:, dest: /var/lib/docker-volumes/netshare/nfs/dockersonarr_sonarr-completed"
time="2016-08-05T10:48:50-04:00" level=debug msg="exec: mount -v -t nfs4 dockersonarr_sonarr-completed: /var/lib/docker-volumes/netshare/nfs/dockersonarr_sonarr-completed\n"
2016/08/05 10:48:50 mount.nfs4: Failed to resolve server dockersonarr_sonarr-completed: Name or service not known

Notice that its oddly trying to resolve the volume name as the nfs host? Whats interesting is that I downed the deluge service that worked before, deleted the volume and attempted to up -d and saw the exact same results. I couldnt mount the NFS volume anymore.

Any thoughts?

Oh and for what its worth, if I run docker manually on the host it works and I can list and work with files in the directory.

docker run --rm -i -t --volume-driver=nfs -v some-host/some/path:/volumes/test ubuntu /bin/bash

Running docker engine version 1.12 and docker-compose 1.8 and docker-volume-netshare_0.18

chkelly avatar Aug 05 '16 14:08 chkelly

So this is interesting, but looking through the code a bit, and the logs, it looks to me that for some reason it skips over these phase:

(logs from a successful mount)

time="2016-08-05T11:06:54-04:00" level=debug msg="Entering Create:
time="2016-08-05T11:06:54-04:00" level=debug msg="Create volume -> name:

So for some reason it feels it doesnt need to create the directory even though it should. Still diving into it though

chkelly avatar Aug 05 '16 17:08 chkelly

I'm seeing the same error after trying restarting my Docker host on v0.20 of docker-volume-netshare.

nuc@nuc:~$ sudo systemctl status docker-volume-netshare.service
● docker-volume-netshare.service - Docker NFS, AWS EFS & Samba/CIFS Volume Plugin
   Loaded: loaded (/lib/systemd/system/docker-volume-netshare.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2016-09-03 11:38:14 AEST; 4min 22s ago
     Docs: https://github.com/gondor/docker-volume-netshare
 Main PID: 4792 (docker-volume-n)
   CGroup: /system.slice/docker-volume-netshare.service
           └─4792 /usr/bin/docker-volume-netshare nfs

Sep 03 11:43:09 nuc systemd[1]: Started Docker NFS, AWS EFS & Samba/CIFS Volume Plugin.
Sep 03 11:43:09 nuc docker-volume-netshare[5287]: time="2016-09-03T11:43:09+10:00" level=info msg="== docker-volume-netshare :: Version: 0.19 - Built: 2016-07-10T08:08:53-07:00 =
Sep 03 11:43:09 nuc docker-volume-netshare[5287]: time="2016-09-03T11:43:09+10:00" level=info msg="Starting NFS Version 4 :: options: ''"
Sep 03 11:43:41 nuc docker-volume-netshare[5287]: time="2016-09-03T11:43:41+10:00" level=info msg="Mounting NFS volume nuc_nzbget: on /var/lib/docker-volumes/netshare/nfs/nuc_nzb
Sep 03 11:43:42 nuc docker-volume-netshare[5287]: 2016/09/03 11:43:42 mount.nfs4: Failed to resolve server nuc_nzbget: Name or service not known

PS. This seems like the same issue reported in #50.

jamesottaway avatar Sep 03 '16 01:09 jamesottaway

Please send me your OS version, Docker version and exact use case thats failing in an email to my first name found on my profile @ containx.io. I will try to correlate the root cause and address this. Thank you everyone :)

gondor avatar Sep 03 '16 04:09 gondor

@chkelly have you tried switching from a hostname to an IP address in the driver_opts: share section of your Compose config? Seems to have helped me, so hopefully it'll work for you too.

jamesottaway avatar Oct 15 '16 05:10 jamesottaway