adlogix / docker-machine-nfs

Activates NFS on docker-machine
MIT License
794 stars 104 forks source link

Only root can write to OSX volumes / Can't change permissions within #32

Closed evbo closed 7 years ago

evbo commented 8 years ago

I followed the directions precisely as given here: https://github.com/boot2docker/boot2docker/issues/581#issuecomment-153512609

Just as in the above example, my docker-machine is named dev-nfs. I do the following operations but nothing is written to my local OSX volume. What could I be missing?

open -a Docker\ Quickstart\ Terminal and then, with the dev-nfs machine as my active docker-machine, I run: docker run --volume ~/mydata --name mydata busybox true docker run --rm --volumes-from mydata --user www-data busybox touch /Users/me/mydata/hello.txt

which results in: touch: /home/docker/mydata/hello.txt: Permission denied

What have I done wrong? How can I write to my OSX computer from the docker VM?

I should note, omitting --user www-data (which I've come to believe is the user that can write to the host?) doesn't throw permissions errors, but still no data appears in my local OSX hard drive under the expected directory (nothing is persisted).

Then, as root the hello.txt is generated but I can only see it in the container (not the host): docker run --rm --volumes-from mydata --user www-data busybox ls /Users/me/mydata/ revealing: /Users/me/mydata/hello.txt

tonivdv commented 8 years ago

Hey @evbo ,

Can you share how you configured nfs for your box. because in the comment you share the user did do it with -maproot=0 , which is now possible since #17

tonivdv commented 8 years ago

Were you able to test this?

evbo commented 8 years ago

sorry, I'm not entirely sure what it means to set maproot. However, I did attempt to apply what I thought it meant to my local machine but it had no affect. Is there a more explicit guide for adding that setting? It's possible I just misread it as I have never edited those configurations on my mac before, nor do I know how to test them other than it works or not. Thanks for the follow up and sorry again for being belated on the reply!

kusmierz commented 8 years ago

edit /etc/exports and find line something like this:

/Users 192.168.99.100 -alldirs -mapall=501:20

and change to:

/Users 192.168.99.100 -alldirs -maproot=0

or just try to run

docker-machine-nfs default -f --nfs-config="-alldirs -maproot=0"
tuscland commented 8 years ago

Hello,

If I use the default configuration (-alldirs -mapall=501:20), the postgres user from the official postgres Docker image can not write to the OS X file system (permission denied).

If I use the -alldirs -maproot=0 NFS configuration, then all is fine, the user from Docker can write to my local file system, but the file now belong to user 999. In the Finder, there is a one-way sign on the directory icon, meaning that the file does not belong to me.

Is there something I miss here? Thank you for your help!

Cam

tonivdv commented 8 years ago

Hey @tuscland ,

Got users that had the same issue with mysql images. I'm not using shared volumes with mysql on os X. I use data containers and then it's no issue.

Not sure if that's helpful for you, but I ignore how to make it work like you describe :(

Cheers

tuscland commented 8 years ago

Thanks, I'll try data containers!