mineshaftgap / d4m-nfs

Docker for Mac with NFS for performance improvements over osxfs
296 stars 26 forks source link

Error with mounting volumes with docker-compose #41

Closed NikitaKharkov closed 7 years ago

NikitaKharkov commented 7 years ago

The error is:

ERROR: for app-quota-api  Cannot start service app-quota-api: Mounts denied: es for more info.
.
rs/admin/la_projects/der-ibe/ibe-quotas-api
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing.
See https://docs.docker.com/docker-for-mac/osxfs/#namespace

image

d4m-nfs/etc/d4m-nfs-mounts.txt

/Users:/Users:0:0
/Volumes:/Volumes
/private:/private

/etc/d4m-nfs-mounts.txt

/Users:/Users:0:0
/Volumes:/Volumes
/private:/private

/tmp/d4m-mount-nfs.sh

ln -nsf /tmp/d4m-apk-cache /etc/apk/cache
apk update
apk add nfs-utils sntpc
rpcbind -s > /dev/null 2>&1

DEFGW=$(ip route|awk '/default/{print $3}')
FSTAB="\n\n# d4m-nfs mounts\n"

if true && ! $(grep ':/mnt' /tmp/d4m-nfs-mounts.txt > /dev/null 2>&1); then
  mkdir -p /mnt

  FSTAB="${FSTAB}${DEFGW}:/Users/admin /mnt nfs nolock,local_lock=all 0 0"
fi

if [ -e /tmp/d4m-nfs-mounts.txt ]; then
  while read MOUNT; do
    DSTDIR=$(echo "$MOUNT" | cut -d: -f2)
    mkdir -p ${DSTDIR}
    FSTAB="${FSTAB}\n${DEFGW}:$(echo "$MOUNT" | cut -d: -f1) ${DSTDIR} nfs nolock,local_lock=all 0 0"
  done < /tmp/d4m-nfs-mounts.txt
fi

if ! $(grep "d4m-nfs mounts" /etc/fstab > /dev/null 2>&1); then
    echo adding d4m nfs config to /etc/fstab:
    echo -e $FSTAB | tee /etc/fstab
else
    echo d4m nfs mounts already exist in /etc/fstab
fi

sntpc -i 10 ${DEFGW} &

sleep .5
mount -a
touch /tmp/d4m-done

/tmp/d4m-nfs-mounts.txt

/Users:/Users:0:0
/Volumes:/Volumes
/private:/private

/etc/exports

# d4m-nfs exports
"/Users" -alldirs -mapall=0:0 localhost
"/Volumes" -alldirs -mapall=0:0 localhost
"/private" -alldirs -mapall=0:0 localhost

-------------------------------------------------------------------------

Looks like the problem is incorrect using strings... I am very weak in this, so I couldn't even assume where the problem is. https://github.com/IFSight/d4m-nfs/issues/32#issuecomment-284417804 - this similar problem in open issue, but the man don't say anything more about it... It's a pity.

I use docker-compose version 3. Maybe in this problem. When I used version 2 with volume_from everything was ok. But then I switched and try to write next lines:

php:
        build: docker/php
        restart: always
        container_name: mc_php
        links:
            - db
        volumes:
            - ./user-api:/var/www/microservice/user-api
            - ./quota-api:/var/www/microservice/quota-api
            - ./gateway-api:/var/www/microservice/gateway-api
NikitaKharkov commented 7 years ago

I spat on everything and decided to reset docker. So I reseted the docker and again did all the thing by tutorial which has this decision and it helped me.

I can add to this issue that I often build container with any different combinations of volumes. Also I delete all possible volumes by commands docker volume rm [names of volumes] every time I rebuild containers. I think in such actions was problem.

NikitaKharkov commented 7 years ago

The error repeating again. I can't do the same thing every time when I have such problem. Any ideas?

if-kyle commented 7 years ago

We do not use docker volume rm very often, so that might be part of it. Sorry I don't have any great advice or ideas.

NikitaKharkov commented 7 years ago

I think the problem is in the cache of your project or something like this. Because the line: .rs/admin/la_projects/der-ibe/ibe-quotas-api implies /Users/admin/la_projects/der-ibe/ibe-quotas-api. So I think that some files writes the volumes after their deleting in incorrect way.

I have no any experience with NFC, maybe you can just check it? You are in subject so you could more effective find the problem. Thanks.

if-kenn commented 7 years ago

@NikitaKharkov You have not given a reason that you think it is a problem with the cache besides a Docker for Mac line that is cut off which we have no control over, and has nothing to do with cache. The only cache which d4m-nfs is involved with is the MobyVM packages which have nothing to do with this.

I have no idea if this is connected to your problem, but when you are exporting /Volumes, you are literally exporting everything on your Mac. The location /Volumes on a Mac is actually just a symlink to /, and it is never good to export a symlink. On top of that, with NFS, you can not export child directories which are on the same file system, and since you are both /Users and /private this could cause problems. The fragment of your docker compose yml certainly does not warrant this. Since you are using relative mounts in the docker compose yml I have no idea where these files are, but I am assuming they are under a directory named /Users/admin. If that is the only directory you are mounting Docker volumes from, then I would suggest to change your d4m-nfs/etc/d4m-nfs-mounts.txt file to this:

/Users/admin:/Users/admin:0:0

You probably will also have to clean up your /etc/exports to remove all the lines from # d4m-nfs exports down.

NikitaKharkov commented 7 years ago

I leave only this string and it's helped me!!! Thank you very much!

UPDATE:

I have to say that error came again and I just changed folder to fix it again. So I made instead /Users/admin:/Users/admin:0:0 /Users/admin/projects:/Users/admin/projects:0:0 and it works normally again. Try to play with folders if this error appears again and again. But I think it's not OK to do that :)

P.S.: Don't forget that you can reset docker image and everything will become ok again. Good luck!