adlogix / docker-machine-nfs

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

setup question #44

Closed agentfitz closed 8 years ago

agentfitz commented 8 years ago

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?

tonivdv commented 8 years ago

Hey @agentfitz ,

You confuse docker engine with docker machine. They are completely different from each other. The docker machine allows to orchestrate (through a common api) a (virtual) machine with the docker engine installed on it. While the docker engine is all about containerizing stuff and run it. On OS X you cannot run the docker engine natively, hence the need for the docker machine.

The most used machine on OS X is virtualbox and this uses a lightweight linux version they call "boot2docker". During the boot it will by default share the "/Users" directory between you host (OS X) and the guest (boot2docker).

Now this share is being mounted with vboxsf, which has not a fast sharing model (but the most portable one). The purpose of this script is to change the mount from vboxsf to nfs which is much much faster (up to 10x depending on the config). In addition it can do some more stuff like share other directories than /Users (e.g. /var/www)

To conclude. Instead of:

docker-machine-nfs jolly_kirch --shared-folder=/Users/brianfitz/www/experiments/docker

It should be

docker-machine-nfs [machine_name]

cd /Users/brianfitz/www/experiments/docker

docker run --name some-nginx -v $(pwd):/usr/share/nginx/html:ro -d nginx

Remember that every docker command you type on your HOST will actually be executed where the docker engine is installed, meaning GUEST. But as we shared /Users (HOST) to /Users (GUEST) we can safely use $(pwd) on our host! Welcome to Docker Inception :)

Hopefully this helps you out.

Cheers

agentfitz commented 8 years ago

Thank you, thank you for the response! You have shared some very valuable information with me. Just one last question if you will allow me to bother you once more.

I actually have the docker-machine (formerly known as boot2docker, I think) installed on OSX and I understand that it is a requirement in order for the docker engine to run on OSX.

That said, in your example above, I still don't know what the [machine_name] should be. Would it simply be "docker-machine", or something else? In other words, how do I find out the "machine name" of my docker-machine?

agentfitz commented 8 years ago

Ah, some more Googling helped me here (now that I knew what to look for, thanks to your help). After running docker-machine inspect I can see that its name is "default". So I'm thinking my command will be:

docker-machine-nfs default
cd /Users/brianfitz/www/experiments/docker
docker run --name some-nginx -v $(pwd):/usr/share/nginx/html:ro -d nginx

Well, at least I'm getting closer. Thanks again @tonivdv!

Brian (ps, I think your "inception" joke was fitting) :)

tonivdv commented 8 years ago

Hey @agentfitz ,

You should actually know which machine you are running as you had to, at one point, do

docker-machine create --driver virtualbox [name_of_the_machine]

It's that name I'm talking about. If you don't remember, you can simply do

docker-machine ls

which will list all machines created on your system.

agentfitz commented 8 years ago

Super helpful, thank you once more. I'll get it eventually!! :)