8

Basically, when you open boot2docker app, inside it you can cd /c/Users, right? Now I want to be able to cd /d to access my D:\ directory.

I don't know squat about VM so please explain like you would to a 5-years old.

This is in a way related to this other question on how to move docker images to another drive. The whole idea is to free up the system disk since docker stuff takes so much space over time.

Community
  • 1
  • 1
jaycode
  • 2,926
  • 5
  • 35
  • 71
  • A better answer (i.e. easier to understand for newbies) is given by this post: http://stackoverflow.com/questions/30864466/whats-the-best-way-to-share-files-from-windows-to-boot2docker-vm – jaycode Mar 01 '16 at 13:56

1 Answers1

8

Answer

In windows CMD(only once):

VBoxManage sharedfolder add "boot2docker-vm" --name "d-share" --hostpath "D:\"

In the Boot2Docker VM terminal(every time you boot):

mount -t vboxsf -o uid=1000,gid=50 d-share /d

If you always want to mount your D:\ to /d you can instead add the following entry to /etc/fstab (if you can edit fstab in boot2docker, not sure on this):

d-share   /d   vboxsf   uid=1000,gid=50  0   0

How I came about this answer, as it may change in the future:

From the Boot2Docker README.md in their git repo

Alternatively, Boot2Docker includes the VirtualBox Guest Additions built in for the express purpose of using VirtualBox folder sharing.

The first of the following share names that exists (if any) will be automatically mounted at the location specified:

  1. Users share at /Users
  2. /Users share at /Users
  3. c/Users share at /c/Users
  4. /c/Users share at /c/Users
  5. c:/Users share at /c/Users

If some other path or share is desired, it can be mounted at run time by doing something like:

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

There's your command structure.

From VirtualBox Guest Additions Docs on Shared Folders

From the command line, you can create shared folders using VBoxManage, as follows:

VBoxManage sharedfolder add "VM name" --name "sharename" --hostpath "C:\test"

and

To mount a shared folder during boot, add the following entry to /etc/fstab:

sharename   mountpoint   vboxsf   defaults  0   0

The default boot2docker vm name is boot2docker-vm (imaginative) and you want to mount the D directory D:\. Lets call our share d-share.

Possible Dupe:

Can be found here, with a slightly differently explained answer to almost the same question.

Community
  • 1
  • 1
Will Barnwell
  • 4,049
  • 21
  • 34
  • Also from the boot2docker README "It is also important to note that in the future, the plan is to have any share which is created in VirtualBox with the "automount" flag turned on be mounted during boot at the directory of the share name (ie, a share named home/jsmith would be automounted at /home/jsmith)." So automount may be useful in the future – Will Barnwell Nov 29 '15 at 21:25
  • RIP no 50 point bounty because OP doesn't check back on question – Will Barnwell Dec 01 '15 at 00:56
  • I see the comment about boot2docker auto-mounting vbox automounts in the future near the bottom of https://git.io/v1q5Q. Do you know which [issue](https://git.io/v1qdJ) that is? – Jamie Jackson Nov 29 '16 at 15:00