adlogix / docker-machine-nfs Goto Github PK
View Code? Open in Web Editor NEWActivates NFS on docker-machine
License: MIT License
Activates NFS on docker-machine
License: MIT License
There's another issue mentioning the problem when a restart changes the IP address of the machine causing the nfs share to break. Since all the IPs are in a set range, it would be nice to have the option to use the range instead.
For instance this works for me, no matter what ip the machine starts on:
#/etc/export
/home/fcarey/docker-share 192.168.99.0/24(rw,sync,no_subtree_check,no_root_squash)
Note these are linux specific settings but the important part is 192.168.99.0/24
Hi,
So I tried to mount a local folder as a volume in my busybox.
docker run -it -v $(pwd)/test:/test busybox
Now I am in the busy box.
The first thing I see is, that the /test folder has the owner 501:20. Why is this so?
Now when I create a file inside the busybox, it gets the owner root, but on my host machine the file has also the owner root. But the owner should be my user. Otherwise I have to do everything as root?
#inside busybox
touch 123
Now when I create a file in my local test folder. In the busybox it has the owner 501:20.
Is there any workaround to map the files to the right user for both, on the host and in the container?
Best Regards,
Michael
I just wanna say thanks. You literally saved me hundred of hours and a lot of pain at my company <3 Insane work. Excellent solution. Much love for you all! ๐
Just found this script and it seems to work great for VirtualBox. But I was just wondering how hard it would be to add VMware Fusion support.
I upgraded to docker-machine 0.3.0 today and the volume no longer mounted inside the VM. Looks to be a timing issue - I added a sleep 10 to the start of the bootlocal.sh script and it seems to be working fine now.
In the newest version (as of today, though ) using the 1.9.0a packages I'm getting a verifying NFS mount error on first run through. Though it works on the second invocation.
Here's the output of docker-machine-nfs default:
[INFO] machine presence ... OK
[INFO] machine running ... OK
[INFO] Lookup mandatory properties ... OK
- Machine IP: 192.168.99.100
- Network ID: vboxnet1
- NFSHost IP: 192.168.99.1
[INFO] Configure NFS ...
!!! Sudo will be necessary for editing /etc/exports !!!
Password:
OK
[INFO] Configure Docker Machine ... OK
[INFO] Restart Docker Machine ... OK
[INFO] Verify NFS mount ... FAIL
Cannot detect the NFS mount :(
Not every terminal supports all colors, so there should be an option to supress them or you get ugly stuff like:
[INFO] Configuration:
\t\033[0;35m- Machine Name: default \033[0m
\t\033[0;35m- Shared Folder: /home/fcarey/docker-share \033[0m
\t\033[0;35m- Mount Options: noacl,async \033[0m
\t\033[0;35m- Force: true \033[0m
[INFO] machine presence ... \033[0;32mOK \033[0m
[INFO] machine running ... \033[0;32mOK \033[0m
[INFO] Lookup mandatory properties ... \033[0;32mOK \033[0m
\t\033[0;35m- Machine IP: 192.168.99.102 \033[0m
\t\033[0;35m- Network ID: vboxnet0 \033[0m
\t\033[0;35m- NFSHost IP: 192.168.99.1 \033[0m
docker-machine 0.8.1
el cap
begin
curl -s https://raw.githubusercontent.com/adlogix/docker-machine-nfs/master/docker-machine-nfs.sh | sudo tee /usr/local/bin/docker-machine-nfs > /dev/null
sudo chmod +x /usr/local/bin/docker-machine-nfs
docker-machine rm dev
docker-machine create -d virtualbox dev
docker-machine-nfs dev --nfs-config="-alldirs -maproot=0"
end
๐๐๐
Cannot detect the NFS mount :(
๐๐๐
docker-machine ssh dev sudo mount -t nfs -o noacl,async 192.168.99.1:/Users /Users
mount: 192.168.99.1:/Users failed, reason given by server: Permission denied
mount: mounting 192.168.99.1:/Users on /Users failed: Bad file descriptor
Hi,
I just installed docker-machine-nfs
and tried to allow NFS on my default machine.
Unfortunately the last step (enabling / verifying) don't work.
I'm working with docker-machine v0.5.0, virtual box as provider and OS X 10.11.2
[INFO] Configuration:
- Machine Name: default
- Shared Folder: /Users
- Force: false
[INFO] machine presence ... OK
[INFO] machine running ... OK
[INFO] Lookup mandatory properties ... OK
- Machine IP: 192.168.99.100
- Network ID: vboxnet0
- NFSHost IP: 192.168.99.1
[INFO] Configure NFS ...
!!! Sudo will be necessary for editing /etc/exports !!!
OK
[INFO] Configure Docker Machine ... OK
[INFO] Restart Docker Machine ... OK
[INFO] Verify NFS mount ... FAIL
Cannot detect the NFS mount :(
Any idea ?
Regards,
I am using docker 1.10.0, virtual box 5.0.14 on OS X 10.10.5.
The NFS shared volumes worked fine for me until I updated docker toolbox from 1.9.0 to 1.10.0 so issue seems related to this update.
After running the script, the /etc/exports on the host has the expected entry, but the df command doesn't list the NFS entry that it used to list. As a result the script errors out with "Cannot detect the NFS mount :(" during the "Verify NFS mount" step.
Hi,
I got an error like that
[INFO] Restart Docker Machine ... /usr/local/bin/VBoxManage showvminfo fast-io --machinereadable failed:
VBoxManage: error: The object is not ready
VBoxManage: error: Details: code E_ACCESSDENIED (0x80070005), callee nsISupports
VBoxManage: error: Context: "COMGETTER(RemoteUSBDevices)(ComSafeArrayAsOutParam(coll))" at line 2022 of file VBoxManageInfo.cpp
at the end of the script.
I can restart the machine after that with docker-machine start mymachine
.
I put it here for instance ;)
I had difficulties solving some shared directories problems with Docker on VMWare Fusion on macOS 10.12. What solved my problem was disabling shared folders for the Docker Machine form inside the VMWare Fusion control panel before running docker-machine-nfs
.
Also, remember to disable any active VPN connections while running docker-machine-nfs
or else it will end up with the wrong IP address for the network share.
Feel free to close this, or if you like, I can PR the README with these instructions.
I was ecstatic to find docker-machine-nfs
when I discovered how slow the vboxfs
performed for running our development environment within containers. Having done some testing with DfM, I'm finding the exact same issues with their osxfs
.
That said, I found a DfM solution very similar to this one, called d4m-nfs. If I'm not mistaken, it's pretty much doing the same thing as docker-machine-nfs
but without most of the bells/whistles/features.
Is this something you'd be able to do?
If not, would you be open to a PR that attempts to add in the support? I'm happy to give it a shot, although I'm far from well-versed in NFS and the different use cases I'd need to test and how to troubleshoot them. Of course, there's a first time for everything!
Hello!
Just wanted to say thank you.
It just works, it's easy to use, and it GREATLY improves performance. โค๏ธ โค๏ธ โค๏ธ โค๏ธ
Just had the same issue as #12 : NFS volume was not mounted due to host network latency. A reboot of my macbook has fixed it.
Does anyone know if it's possible to use NFS/SMB shares on Windows to improve performance?
Asking for a friend (a colleague, actually).
P.S. Sorry for abusing your issues.
I work on projects that uses Vagrant with Virtual Box and Docker with Docker Machine on Mac OS X.
Every time I use Vagrant, and then I switch to my projects with Docker, the docker-machine-nfs gives me an error saying it's conflicting with the current /etc/exports.
The workaround till now is:
The problem is that I'm having to do almost the same thing when have to go back to my other projects using Vagrant.
I took a look at the other issues talking about the /etc/exports usage by this command, though I didn't find any solution.
Help? :)
I just ran: brew update && brew upgrade && brew cleanup
Noticed docker-machine upgraded to 0.5.5, and then had to regenerate the certificates on my docker-machine, which worked fine, so I cleared out the /etc/exports file and ran: sudo nfs restart && docker-machine-nfs dev --nfs-config="-alldirs -maproot=0"
After several attempts, it just hangs at "Lookup Mandatory Properties OK"
I also checked the /etc/exports file which is still empty - guessing the script is hanging somewhere before that.
Any ideas?
Howdy,
Instead of using the system NFS, attempt to use unfs3's unfsd
as an unprivileged nfs server for use with docker-machine. This is a cross-platform userspace server, so can be used in a bunch of different places.
I've got an error:
[INFO] Configure NFS ...
!!! Sudo will be necessary for editing /etc/exports !!!
exports:5: /Users conflicts with existing export /Users/adam/Projects/my-project
Currently the /etc/exports file gets configured with:
-mapall=$(id -u):$(id -g)
However it seems for some (#14) this causes permissions issues and needs to be replace with some other values or be substituted with -maproot=0
The idea would be to allow to send the /etc/exports params through the docker-machine-nfs command:
E.g.
./docker-machine-nfs [machine] --nfs-exports="-maproot=0"
We found an interesting edge case today when using this script with a VirtualBox instance that has more than 10 hostonly interfaces. VirtualBox names the interfaces vboxnet1, vboxnet2...etc all the way to vboxnet10, vboxnet11.
Since it does not pad it's interface numbers with 01, 02 this allows the following line to grab too many IPs.
VBoxManage list hostonlyifs | grep "${prop_network_id}" -A 3 | grep IPAddress | cut -d ':' -f2 | xargs
This will grab multiple IPs because the grep clause will match on vboxnet1, vboxnet10, vboxnet11. The way we were able to fix this is by changing the grep to be this, grep "${prop_network_id}$" -A 3
I will work on getting this to you in a PR.
When we have for example two machines with similar names:
- machine30
- machine30trans
And we want to mount these two machines with docker-machine-nfs there is a problem when:
machine30trans
- OKmachine30
- FAIL with message:exports:2: got host/group with no directory?: trans
after running above instructions /etc/exports
looks like:
trans
# docker-machine-nfs-begin machine30
/Users 192.168.99.100 -alldirs -mapall=1440676671:1381159979
# docker-machine-nfs-end machine30
IMO it's because there is a bug somewhere in code responsible for replacing content in /etc/exports
.
For example when we want to mount machine30
- script makes search and replace texts which begins with machine30
word and when there is already mounted machine30trans
- script removes only machine30
text and left unnecessary trans
word.
The problem doesn't occurs when we firstly mount machine30
and secondly machine30trans
OS version: 10.12.3
Parallels version: 12.1.3
Attempting to share the user directory fails at the Verify NFS mount
message.
It is confusing to read the function declarations that mention boot2docker, but as far as I can tell boot2docker
is not used. Since docker-machine
is the future, it would be best to refactor so that boot2docker is not mentioned.
Many thanks for creating docker-machine-nfs, it is a much better solution to buggy virtual machine shares or overly specialized solutions such as Dinghy.
However, NFS can become a pain point with the security and permission issues which often arise. User-space NFS seems to be the solution to many of these problems.
Please review the following fork for a functional implementation using UNFS3:
https://github.com/erikwilson/docker-machine-unfs
Here are some advantages to using unfsd vs the system nfsd:
Disadvantages to switching to unfsd:
Other advantages to the unfs branch that can be backported:
I would submit the fork as a pull request but am hoping for some feedback first. I have experienced some issues with nfs where docker doesn't seem to perform virtual mappings correctly but reports 'Cannot link to a non running container' if there are any linked containers. The solution seems to be removing containers before starting (eg docker-compose rm), rather than killing them.
/usr/local/bin/docker-machine-nfs: line 130: syntax error: unexpected "(" (expecting "}")
Boot2Docker version 1.9.1, build master : cef800b - Fri Nov 20 19:33:59 UTC 2015
Hello ;)
I have been trying to get PM2/nodemon NodeJS hot-reload working. I tried I lot of different approaches and arrived here. I looked for an example and could not find. How can use it?
Cheers!
I followed the directions precisely as given here: boot2docker/boot2docker#581 (comment)
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
Allow to specify one or more directories to mount.
Having vagrant shares in /etc/exports, the /Users one conflicts
I know, why on earth would you want to install docker-machine + virtualbox to setup docker on a linux host? .. well we do, mostly for parity with the few devs who run linux instead of OSX. I'm going to tool around with this and see what I can get working.
Add an option to share folders with boot2docker as NFS server and OSX as client.
This is useful for situations where the underlying filesystem needs to be a Linux filesystem.
Hey there,
It would be great if it was possible to use different NFS options for different shared folders. For example, I want to share /Users with the standard "-alldirs -mapall=$(id -u):$(id -g)" setup, but I want to share another directory with "-alldirs -maproot=0". This isn't currently possible, as all shared folders share the same options. Any ideas?
Strange thing is it has worked before, but not anymore.
[INFO] machine presence ... OK
[INFO] machine running ... OK
[INFO] Lookup mandatory properties ... OK
- Machine IP: 192.168.99.100
- Machine VBOXNET name: vboxnet0
- Machine VBOXNET ip: 192.168.99.1
[INFO] Configure NFS ...
!!! Sudo will be necessary for editing /etc/exports !!!
Password:
OK
[INFO] Configure Boot2Docker ... OK
[INFO] Restart Boot2Docker ... OK
[INFO] Verify NFS mount ... FAIL
Cannot detect the NFS mount :(
My versions:
docker-machine version 0.4.1 (e2c88d6)
Docker version 1.8.1, build d12ea79
I'm on OS X 10.11.1 Beta.
Hey guys,
This is not really a bug but just trying to gain some understand of what's going on... I've been running docker-machine-nfs for a while now... tried to switch to docker for mac a few times but I just can't stomach the slow speed.... how can they push that product so hard when it's so bad at performance... doesn't anyone else have the same issues?
For example I'm running the same site, same db, same codebase... on a new mbp 2016 that I just installed and this is the results of a WordPress backend...
Docker for mac (16s load time)
http://i.imgur.com/EyV50vO.png
Docker toolbox (6s load time)
http://i.imgur.com/fKGmhgD.png
Docker toolbox NSF mounted (https://github.com/adlogix/docker-machine-nfs) (2s load time)
http://i.imgur.com/lk0LhNL.png
Horrible... anyone else experiencing the same thing?
Saying that is docker-machine-nfs something that will be made available for docker for mac? I'm really hoping they don't EOL docker toolbox anytime soon.
Thanks
Just tried using this on vm under parallels driver. It fails on me with Cannot detect the NFS mount :(
and natively mounted volume is also gone now. Any tips on how to revert this without recreating the vm?
Forgive me, @tonivdv, for being slow, but I'm not getting it.
I gave this a try and saw the exact same as the screencast video on the readme.md page, but now I'm left wondering, ok, how do I use this to map directories on my host to directories on containers?
I apologize for the newb question, but I am having trouble getting this setup. This is the command I am running from my HOST machine (Macbook):
docker-machine-nfs jolly_kirch --shared-folder=/Users/brianfitz/www/experiments/docker
I have tried the 'jolly_kirsh' which is a running docker container name, and 'lucee/lucee4-nginx' which is a docker image name.
This results in:
FAIL - Could not find the machine 'jolly_kirch'!
FAIL - Could not find the machine 'lucee/lucee4-nginx'!
What is the supposed to be? Conceptually I don't understand this as I would also expect to provide two folders 1) the folder on the host machine and 2) the folder it should sync to in the docker container. Am I way off here?
Is it possible to mount an additional location say /opt/docker
in addition to /Users
?
I'm running a rails application in a container with the root directory as a volume.
Excerpt from docker-compose.yml:
app:
image: "some/image:tag"
command: "bundle exec rails s -b 0.0.0.0"
volumes:
- "./:/var/www"
links:
- db
- redis
ports:
- "80:3000"
environment:
- ...
When I use the standard virtual box sharing, it takes about 10 seconds to load a single page. With docker-machine-nfs it takes about 2 seconds. I also tried https://github.com/brikis98/docker-osx-dev, which uses rsync. With docker-osx-dev a page load takes about 200ms.
Is this performance hit realistic or did I do something wrong?
PS: I would use docker-osx-dev, but unfortunately the rsync sharing works only in one direction...
I was running docker-machine using vboxsf on my mac, when I run the following command
docker run -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -P -v $(pwd)/data:/var/lib/mysql mysql:5.6
It fails to mount the volume with correct permission, so no data can be written to the directory
Then I use docker-machine-nfs to mount /Users, then the command returns
chown: changing ownership of '/var/lib/mysql/': Operation not permitted
Did I miss something?
Is it possible? E.g. my NAS at home exports NFS shares to my Mac. I want a Docker container running on my Mac to access the NAS.
Getting the following error when running:
exports:8: /Users conflicts with existing export /Users/josh/github
I am on an older version of VBox and docker-machine so will attempt upgrading.
After a few hours of troubleshooting and trying every method I could think of to mount a nfs volume in my docker-machine, I figured out that the bootlocal.sh
was just left empty.
I wrote the bootlocal.sh
file manually to make it work.
Not entirely sure where that goes wrong though. I'm using OS X 10.11.1 and running docker-machine 0.5.5.
It would be nice if the exported mount is configured for the whole /24 ip space for the host only network. The VM ip changes sometimes so it would be nice to not have to rerun the script when that happens.
Hey guys could use some help here.. got everything working properly.. I'm also exposing mariadb to a mounted volume so data is persistent.
The problem is I can set everything up... run docker-compose build, then docker-compose up, I see the db folder gets built by mariadb (those files are restricted to osx root only user) and things are running fine.
However when I run another docker-compose build command I run into issues from my php container complaining about access to the db folder which is setup from mariadb container... I'm not sure if this has something to do with /etc/exports and permissions of that folder but I can't build anything else unless I delete the db folder in the root...
I'm not sure if any of the options for docker-machine-nfs will help with this issue...
`#docker-machine ip default web: build: . container_name: web ports: - "9090:80" volumes: - /Users/bartdabek/Sites/hgv/hgv_data/sites/:/code - ./site.conf:/etc/nginx/conf.d/site.conf - ./nginx.conf:/etc/nginx/nginx.conf - ./sites-enabled:/etc/nginx/sites-enabled links: - php #- mariadb - memcached php: container_name: php build: . dockerfile: Dockerfile-php volumes: - /Users/bartdabek/Sites/hgv/hgv_data/sites/:/code - ./Tideways.php:/usr/local/lib/php/extensions/no-debug-non-zts-20151012/Tideways.php links: #- mariadb - memcached memcached: container_name: memcached image: sameersbn/memcached:latest ports: - "11211:11211" restart: always mariadb: container_name: mariadb image: mariadb volumes: - /Users/bartdabek/Sites/docker/db/:/var/lib/mysql environment: DB_ADMIN_PASS: pass MYSQL_ROOT_PASSWORD: root ports: - "3306:3306" `
The configuration and cleanup of the /etc/exports file should be improved. Using the technique of Vagrant could be a good approach:
# VAGRANT-BEGIN: 21171 5b8f0135-9e73-4166-9bfd-ac43d5f14261
"/path/to/vagrantfile" 172.28.128.5(rw,no_subtree_check,all_squash,async,anonuid=21171,anongid=660,fsid=3382034405)
# VAGRANT-END: 21171 5b8f0135-9e73-4166-9bfd-ac43d5f14261
We should probably use the docker-machine name and would be something like:
# DOCKER-MACHINE-NFS-BEGIN: machine-box
/Users 192.168.99.100 -alldirs -mapall=501:20
# DOCKER-MACHINE-NFS-END: machine-box
Things to keep in mind:
Script fails with the following error:
Restart Docker Machine ... Too many retries waiting for SSH to be available. Last error: Maximum number of retries (60) exceeded
I am not able to connect to the machine even with docker-machine ssh
I'm testing this on ubuntu 14.04 (I know.. not OSX.. but I'm trying to setup machine to standardize setups across linux and OSX), but running the command gives an syntax error of :
130: /usr/local/bin/docker-machine-nfs: Syntax error: "(" unexpected (expecting "}")
.. which is related to the creation of an empty bash array.
Is there a reason to not use /bin/bash instead, which resolves this specific issue?
So, if we want to uninstall the nfs support, is there an easy way to do that?
Command tried:
docker-machine-nfs default --shared-folder=/proyectos
The same error happened with command: docker-machine-nfs default
Output error only say:
/usr/local/bin/docker-machine-nfs: 130: /usr/local/bin/docker-machine-nfs: Syntax error: "(" unexpected (expecting "}")
System information:
docker-machine version 0.10.0, build 76ed2a6
Docker version 17.03.1-ce, build c6d412e
docker-compose version 1.8.0, build unknown
Linux xxxxxx 4.9.0-2-amd64 #1 SMP Debian 4.9.13-1 (2017-02-27) x86_64 GNU/Linux
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VirtualBox Graphical User Interface Version 5.1.18 r114002 (Qt5.7.1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.