Closed motin closed 7 years ago
This is rather ugly, but works, wrapping the following in a shell-script:
export PWDNFS="${PWD/\/Users\/$USER//mnt}"
stack/d4m-nfs/d4m-nfs.sh && docker-compose --file docker-compose.nfs.yml up
Then in docker-compose, instead of
- .:/app:rw
Use:
- $PWDNFS:/app:rw
Un-mounting /Users is reported to restart the Moby VM which would then leave you in a state that does not have NFS. So a bit of the dragon eating it's own tail.
I think your above solution is a decent one, I could add it to the repo as a wrapper script or put it on the README.md.
You may use the Docker for Mac file sharing preferences to remove /Users as osxfs mount point. My Moby VM is running that way.
@fuerst you are absolutely correct. Since some people need a drop in replacement and can't/don't want to change their compose file, I have made it so that you specify mounts in d4m-nfs/etc/d4m-nfs-mounts.txt
. You will has you said have to remove the /Users under the D4M Preferences -> File Sharing.
https://raw.githubusercontent.com/IFSight/d4m-nfs/master/examples/img/d4m-min-file-sharing.png
@motin I don't know if this new mounting system works for your relative path use case, but you might want to check it out.
@motin i just confirmed that the relative paths are now functioning with the new custom mounting, as noted you will need to add to /Users to d4m-nfs/etc/d4m-nfs-mounts.txt and remove from D4M Preferences -> File Sharing.
Let me know if this work for you so I can close this issue.
@if-kenn Yes, relative paths works! No modification of the existing docker-compose.yml is necessary when /Users is only exported via nfs. Awesome!
A note: I ran into many of these after having added /Users:/Users to d4m-nfs-mounts.txt
exports:6: /Users conflicts with existing export /Users/motin
Had to empty /etc/exports since the contents was conflicting.
Here was the contents of /etc/exports before clearing it:
"/Users/motin" -alldirs -mapall=501:20 localhost
# d4m-nfs exports
"/Users" -alldirs -mapall=501:20 localhost
@motin: That's a left over from the former behaviour of d4m-nfs.sh
to export your home directory. Removing it manually from /etc/exports
is the right thing to do.
It would be great to see an example d4m-nfs-mounts.txt file which allows for mounting directories from within the home directory using a relative path in a docker-compose file. The discussion here indicates that it's possible to do this by adding /Users:/Users
to the mount specifications but I'm not having any luck with this.
Here is my config:
d4m-nfs-mounts.txt:
/Users:/Users
/Volumes:/Volumes
/private:/private
docker-compose.yml:
volumes:
# - /mnt/workspace/example/services/api:/app
- ./services/api:/app
In this example, the commented out line (the one that uses an absolute path starting with /mnt) works if I remove /Users:/Users
from the mont file. The relative mount (./services/api:/app
) doesn't work with or without /Users:/Users
in the mount file - I get the following:
ERROR: Cannot start service api: Mounts denied: xfs/#namespaces for more info.
.
ace/example/services/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/o
@mrfelton the truth is that it is difficult to try and provide an example for everyones specific use cases since it is so individualized.
When we get time we will look to add more information, but right now I do not have any free cycles to do so. I am open to people making pull requests to help with the documentation.
@if-kenn I'll happily create a PR with some examples and better documentation if I can get it working in the first place. Can you confirm if what I'm trying to do is possible (use a relative path in docker-compose exactly as normal without any changes to accommodate /d4m-nfs), or do I need to create a wrapper script to do this like the one @motin described?
@mrfelton it should be possible per the previous advise:
i just confirmed that the relative paths are now functioning with the new custom mounting, as noted you will need to add to /Users to d4m-nfs/etc/d4m-nfs-mounts.txt and remove from D4M Preferences -> File Sharing.
ok, thanks @if-kenn . Unfortunately this doesn't work as described as shown in my example above. I'll keep trying different variations to see if I can get something that works but at the moment its looking like this cane be done without modifying the docker-compose file. My guess is that @motin had something else in play when he got this working that he forgot to mention here!
@if-kenn - I have it working. Actually, the configs were correct and the original poster is correct. Restarting docker and then rerunning the setup script got it going.
From what I can tell once you have run the script to get things going there are some issues reconfiguring things. My approach was to delete the contents of /etc/exports and rerun d4m-nfs.sh however changes do not seem to take effect when doing this (I checked by jumping into the d4m screen session and checking what had been mounted in and verified that the changes that I made to the mount points did not result in those directories actually being mounted in properly).
The only fail safe way that I have found to reconfigure the service is to restart D4M and then rerun the setup script.
Our docker-compose files do not contain /Users/$USER - they use relative paths for portability. What would be the elegant way to adapt these to use d4m-nfs? Could we for instance unmount /Users and put osxfs on /mnt instead?