coreos-osx icon indicating copy to clipboard operation
coreos-osx copied to clipboard

docker host volumes

Open whitlockjc opened this issue 9 years ago • 9 comments

Have you tried using docker run with a host volume? Within the docker container, the container directory is there but the contents are always empty. Here is an example:

$ docker run --rm --name build-dex -v $GOPATH:/go golang:latest ls -l /go
total 0

What I expect is this:

ls -l $GOPATH
total 0
drwxr-xr-x  38 notyou  staff  1292 Aug 10 16:11 bin
drwxr-xr-x   3 notyou  staff   102 Feb  2  2015 pkg
drwxr-xr-x  13 notyou  staff   442 Jul 14 15:13 src

This could be a Docker question but from what I can tell, it should work and I'm using the right syntax. Maybe my system needs a reboot...

whitlockjc avatar Aug 11 '16 18:08 whitlockjc

I'm an idiot. The issue is that the host is not my OS X box but my CoreOS VM.

whitlockjc avatar Aug 11 '16 18:08 whitlockjc

Wait, that's not totally true either because the CoreOS VM mounts this. But...I do think I read somewhere that Docker mounts and NFS do not play nicely so it would seem that is the issue. I verified this (to a degree) by mounting a non-NFS directory in the CoreOS VM and it works as expected.

whitlockjc avatar Aug 11 '16 18:08 whitlockjc

I'm reopening this because I want to get your opinion on installing a Docker Volume Plugin to allow this: http://netshare.containx.io/docs/getting-started

whitlockjc avatar Aug 11 '16 18:08 whitlockjc

yes, docker sucks with NFS volumes in our case. never tried that Docker Volume Plugin, I just usually end up doing rsync. @AntonioMeireles what do you think?

rimusz avatar Aug 12 '16 08:08 rimusz

I just ran into this again trying to build minikube against a custom build of Kubernetes:

if [ ! -e /Users/notyou/workspaces/personal/minikube/src/k8s.io/minikube/_gopath/src/k8s.io ]; then mkdir -p /Users/notyou/workspaces/personal/minikube/src/k8s.io/minikube/_gopath/src/k8s.io && ln -s -f /Users/notyou/workspaces/personal/minikube/src/k8s.io/minikube /Users/notyou/workspaces/personal/minikube/src/k8s.io/minikube/_gopath/src/k8s.io; fi
docker run -w /go/src/k8s.io/minikube -e IN_DOCKER=1 -v /Users/notyou/workspaces/personal/minikube/src/k8s.io/minikube:/go/src/k8s.io/minikube gcr.io/google_containers/kube-cross:v1.6.2-1 make out/localkube
make: *** No rule to make target 'out/localkube'.  Stop.
make: *** [out/localkube] Error 2

Following the "Updating Kubernetes" section of kubernetes/minikube, when I get to the point where I run make, I get the error above. This is because the approach minkube uses is to build within Docker using host volumes.

whitlockjc avatar Sep 02 '16 00:09 whitlockjc

By the way, I'm not looking to leave kube-solo for minikube, I am trying to run a local developer build of Kubernetes. If you have a better way to do this...

whitlockjc avatar Sep 06 '16 17:09 whitlockjc

@whitlockjc sorry been away for the conference, and too busy this week. the best would be use rsync to copy code to VM and mount VM's drive to docker

rimusz avatar Sep 06 '16 17:09 rimusz

If you've got an example, that would be cool. If not, I'll figure it out.

whitlockjc avatar Sep 06 '16 17:09 whitlockjc

usually I trigger code copying with rsync via post commit hook

rimusz avatar Sep 06 '16 17:09 rimusz