Map host drive on aws

I’m on osx and used docker-machine to create a virtualbox host. When I run this it works as I’d expect:

docker -it run -v $(pwd):/backup debian /bin/bash

That puts me into the shell inside the container and I can cd into /backup and see the contents of the directory of the osx host terminal.

I also used docker-machine to create a aws ec2 host. When I run the same command against aws, and cd into /backup, I don’t see the contents of the directory of my macbook. ls /backup appears empty in the container running in aws.

Shouldn’t this work the same way on aws as it does with virtualbox? Or maybe there’s some extra magic setup on virtualbox?

I noticed that aws is using an ubuntu amazon image whereas virutalbox is running a boot2docker image. Maybe boot2docker virtualbox has something special configured?

Hi,

When you are using docker volumes on OSX with docker-machine and virtualbox, there is a VirtualBox specific magic happening in the backend. Docker machine is actually mounting (VirtualBox Shared Volumes) OSX’s /Users directory into the boot2docker VM when the VM starts.

You can see this if you enter into the vm and check the mounted volumes.

docker-machine ssh dev
# Now i am inside vm
docker@dev:~$ mount | grep vbox
none on /Users type vboxsf (rw,nodev,relatime)

You can verify this from the VirtualBox GUI too, if you look at the settings of the vm created by docker-machine.

Now when you mount volume starting as /Users/<username>/some/dir its actually attaching it from within the VM. If you try to mount any directory outside /Users you wont see OSX’s directory inside the container.

So finally this magic doesnt happen with Docker-Machine when used with ec2.

Regards

1 Like

Thanks ranjandas, I thought that might be the case, thanks for the explanation, that’s the missing piece.

Dave