Move boot2docker and .docker folder in other drive
Asked Answered
N

3

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 ?

Nonconformance answered 28/10, 2015 at 13:18 Comment(1)
What version of docker are you using? Are you using docker-machine?Mauldon
P
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

Pesce answered 13/11, 2015 at 7:53 Comment(5)
Hi, I found the files you mentioned in C:\Users\USERNAME\VirtualBox VMs\boot2docker-vm directory. Do I copy the .vbox file as well?Infancy
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)Infancy
Thx Larry for your solution, the storage-path is fine. GreetingsNonconformance
@Infancy I solved the UUID problem by copying the hardisk not in the system explorer, but via VirtualBox ->File->VirtualMediaManager ->CopyBorneol
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 ).Atchley
E
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.
Expellee answered 13/11, 2015 at 19:43 Comment(10)
@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.Expellee
mklink looks interesting, i also noticed the --storage-path in another link, so I added there as well. not tried kitematicPesce
I can't seem to find .Docker file in C:\ , anywhere else this might be?Infancy
@jaycode, this is a directory, not file. It should be under user home directory at disk C, just updated my answerExpellee
@OleksandrHorobets, I see .boot2docker directory there, but not .docker. Is there another way to find this directory perhaps?Infancy
This is perhaps relevant to this issue: https://mcmap.net/q/53155/-where-are-docker-images-stored-on-the-host-machineInfancy
@jaycode, perhaps you're using old version of Docker. Could you please clarify versions of Docker/Boot2Docker/docker-machine/docker-toolbox?Expellee
@jaycode, please check this directory (.boot2docker) size and content. Does it contain vmdk files? Usually disk size could be up to several GBs.Expellee
Let us continue this discussion in chat.Infancy
Alright, now, how do I access D:\ drive from boot2docker? check this question out: #33808391Infancy
H
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".

Havens answered 31/1, 2017 at 8:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.