20

I'm new in docker. I have installed docker in windows in the D drive but the Boot2docker VM is in the user folder in the C drive.

I dont have enough space in the C and the boot2docker is growing when i pull softwares from the docker hub.

So I want to move the boot2docker or the .docker folder in the D drive.

Is it possible ? and how can i do ?

berzeker
  • 203
  • 2
  • 5

3 Answers3

19

Moving existing disk

The big size for the VM machine is .vmdk or .vdi, so you just need to move the disk to Drive D instead of moving whole .docker directory.

What you can do in simple way in Oracle VirtualBox Manager GUI:

  1. Stop the boot2docker VM, and find the place disk.vmdk under Setting->Storage
  2. Copy the disk.vmdk to Disk D (any place)
  3. Detach (-) the disk.vmdk in VirtualBox Manager
  4. Attach (+) the new disk.vmdk from Disk D. make sure the SATA port number is the same
  5. Verify the boot2docker env, if not, try to find the reason
  6. Remove the disk.vmdk in Disk C to save space if migration is finished.

It shall work as I am always lack of disk space and move those disks around

For new created disk

Normal it will create to your use default user directory, but it is possible to redirect to new place by using flag --storage-path during creation

$ docker-machine --storage-path f: create -d virtualbox dev

see related questions in How can I make docker-machine create a VM in a specific location

Community
  • 1
  • 1
Larry Cai
  • 55,923
  • 34
  • 110
  • 156
  • Hi, I found the files you mentioned in C:\Users\USERNAME\VirtualBox VMs\boot2docker-vm directory. Do I copy the .vbox file as well? – jaycode Nov 17 '15 at 13:16
  • 1
    Failed to open the hard disk file D:\Docker\boot2docker-vm\boot2docker-vm.vmdk. Cannot register the hard disk 'D:\Docker\boot2docker-vm\boot2docker-vm.vmdk' {9a4ed2ae-40f7-4445-8615-a59dccb2905c} because a hard disk 'C:\Users\Jay\VirtualBox VMs\boot2docker-vm\boot2docker-vm.vmdk' with UUID {9a4ed2ae-40f7-4445-8615-a59dccb2905c} already exists. Result Code: E_INVALIDARG (0x80070057) Component: VirtualBox Interface: IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554} Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001) – jaycode Nov 17 '15 at 14:06
  • Thx Larry for your solution, the storage-path is fine. Greetings – berzeker Nov 20 '15 at 21:39
  • 5
    @jaycode I solved the UUID problem by copying the hardisk not in the system explorer, but via VirtualBox ->File->VirtualMediaManager ->Copy – lib Jan 27 '16 at 11:42
  • 1
    If you want to specify a specific folder rather than a drive ("f:") you can change the start.sh file in the docker installation folder; however, use something like d:/docker rather than d:\docker (/ rather than \). – yoavram Mar 23 '16 at 07:14
18
  1. Stop boot2docker VMs
  2. Copy the file C:\Users\$USERNAME\VirtualBox VMs\boot2docker-vm\boot2docker-vm.vmdk to drive D: (don't delete it just yet).
  3. Open Oracle VM VirtualBox Manager app.
  4. Open File / Virtual Media Manager.
  5. Release and remove boot2docker-vm.vmdk.
  6. Back to main panel. Right click on boot2docker-vm, choose Settings.
  7. Choose Storage.
  8. Add harddisk, then choose boot2docker-vm.vmdk from new location.
jaycode
  • 2,926
  • 5
  • 35
  • 71
Oleksandr Horobets
  • 1,335
  • 14
  • 26
  • @Larry, correct, it works for existing VM, but if you try to create new VM using `docker-machine create`, new VM will be created on disk C, not D. With my solution every new machine will be on disk D. – Oleksandr Horobets Nov 14 '15 at 09:31
  • mklink looks interesting, i also noticed the --storage-path in another link, so I added there as well. not tried kitematic – Larry Cai Nov 15 '15 at 12:57
  • I can't seem to find .Docker file in C:\ , anywhere else this might be? – jaycode Nov 17 '15 at 12:50
  • @jaycode, this is a directory, not file. It should be under user home directory at disk C, just updated my answer – Oleksandr Horobets Nov 17 '15 at 12:57
  • @OleksandrHorobets, I see .boot2docker directory there, but not .docker. Is there another way to find this directory perhaps? – jaycode Nov 17 '15 at 13:10
  • This is perhaps relevant to this issue: http://stackoverflow.com/a/25170003/278191 – jaycode Nov 17 '15 at 13:15
  • @jaycode, perhaps you're using old version of Docker. Could you please clarify versions of Docker/Boot2Docker/docker-machine/docker-toolbox? – Oleksandr Horobets Nov 17 '15 at 13:25
  • @jaycode, please check this directory (.boot2docker) size and content. Does it contain vmdk files? Usually disk size could be up to several GBs. – Oleksandr Horobets Nov 17 '15 at 13:27
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/95356/discussion-between-jaycode-and-oleksandr-horobets). – jaycode Nov 17 '15 at 14:14
  • Alright, now, how do I access D:\ drive from boot2docker? check this question out: http://stackoverflow.com/questions/33807891/windows-boot2docker-how-to-add-d-drive-to-be-accessible-from-within-docker – jaycode Nov 19 '15 at 15:25
2

You can store the images outside of the VirtualBox images. You don't have to move the disk. I like this idea, because the disk by VirtualBox is limited, but if you host in the host, in have the same storage that the host have.

Do it by using VirtualBox shared folder option. I was able to use a folder in C:\ drive, for all the data that docker needs.

To do so you have to mount /var/lib/docker to a local folder in your host machine. Set "Auto-Mount", but do not set "Read-Only".

Aminadav Glickshtein
  • 23,232
  • 12
  • 77
  • 117