4

Using docker client, is there a way to share a folder in windows with a docker container without having to first share the folder via the Virtual Box VM.

Have understood the need of having a double slash from this and this

Ran the following command from the docker client for windows

docker run -it -v //F/devfolder:/development/windev <imagename> <cmdname>

but when did a ls on /development/windev , it turned out it was empty.

I did not have any problem when I tried mounting the c/Users/username folder via the following command

docker run -it -v //c/Users/username/desktop:/development/windev <image> <command>

and the windev folder listed the contents as I would expect it to be

Tried sharing F/devFolder via Virtualbox GUI and gave full access but still the contents of the folder is not listed.

[I am not using boot2docker but docker-machine]

Is it not possible to share any other folder than the c/Users/ folder? If yes, anything else I need to do to ensure that I can see the contents of the mounted folder?

shrivb
  • 1,391
  • 3
  • 12
  • 20

1 Answers1

3

Not only you have to mount it in your VirtualBox, but you also have to instruct, in your boot2docker TinyCore session that you want that folder visible (once you have done a docker-machine ssh yourMachine):

mount -t vboxsf -o uid=1000,gid=50 your-other-share-name /some/mount/location

I know that you are using docker-machine, and not boot2docker, yet docker-machine is still using a boot2docker.iso VM image based on TinyCore, so this command still applies.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • Also this might be helpful to not confuse the share-name with a folder path http://serverfault.com/questions/674974/how-to-mount-a-virtualbox-shared-folder – shrivb Nov 26 '15 at 11:09
  • @JohnSam yes. Was able to get the windows folder mounted correct. – shrivb Nov 29 '15 at 09:28
  • @But without use VirtualBox UI, I can use only docker-machine to mount other folders? –  Nov 29 '15 at 13:20
  • @JohnSam I guess so to mount the folders without VBox UI though I used the VBox UI.It involved 2 steps. First use the Virtual box UI to configure a share folder. Steps I did are as follows: 1. First share the folder in Virtual box UI. Share name in VBox is DevEnv 2.docker-machine.exe ssh default 'sudo mkdir --parents //f/v1/Dev' 3.docker-machine.exe ssh default 'sudo mount -t vboxsf DevEnv //f/v1/DevEnv' Then run the docker container 4.docker run -it -v //f/v1/DevEnv:/development/windev bash – shrivb Nov 30 '15 at 06:17
  • I need to use only docker-machine code in shell, not virtualbox ui. It woks? I don't think so. –  Nov 30 '15 at 08:40
  • @JohnSam with shell command, that would be using VBoxManage: https://www.virtualbox.org/manual/ch04.html#sharedfolders – VonC Nov 30 '15 at 08:45
  • No, I would use Docker like vagrant. Vagrant uses vagrant folder automatically. How with Docker? –  Nov 30 '15 at 10:25
  • @JohnSam Docker, use in a VM managed by VirtualBox, automatically uses `C:\Users` (as `/C/Users`). – VonC Nov 30 '15 at 10:28
  • I have all my project in other drive like D:/projects. Can I use a symlink? Because I need to work on files with my editor. –  Nov 30 '15 at 10:31
  • @JohnSam No: symlink is not supported by the tiny-core based image used by VirtualBox as a VM for docker. You need to mount `D:/project` both in VirtualBox (VBoxManage) and in TinyCore (see my answer above) – VonC Nov 30 '15 at 10:33