Reputation: 1541
I am using docker toolbox on Windows 7 to run docker. (docker version 1.9.1)
As it turns out, the docker machine creates its VM at C:\Users\username\.docker\machine\machines\default. As I commit the images, the size of VM at this location bloats up. Since it's Windows, I can't afford the luxury of space on the C drive.
Is there any way I can change the location of the default machine?
Upvotes: 79
Views: 73388
Reputation: 1
For windows 7:
copy paste your disk.vmdk file (for me it's present at C:\Users\name.docker\machine\machines\default\disk.vmdk) to a place where you want to store your images that you download (basically disk.vmdk is what will grow in size when you are using docker)
in Virtualbox Right-click default image and goto settings Select Storage remove disk.vmdk attachment by right-clicking --> remove
click on file --> virtual media manager and remove disk.vmdk from here also
Right-click default image --> storage --> add hard disk (this option is just above that iso image)Now select that disk.vmdk that you have pasted somewhere
change now this path in config.json (C:\Users\name.docker\machine\machines\default\config.json) change the storage path with this new one where u put the location of your hard disk ( "StorePath": "F:\docker-image")
save.
Upvotes: 0
Reputation: 481
Install Docker Toolkit and VM must be installed with Admin Privileges after the installation of docker toolkit (*because Docker Toolkit also installs VM but it's of lower version and creates a problem with other iso files, u can uncheck also, in that case, *). Now we have to change the location of disk.vmdk and update the new location in VM.
VirtualBox.exe
(Not the installer) is present and right-click on it (you can find from the shortcut created on your Desktop)run this program as administrator
Kitematic
, If it fails (it will probably) then select option provided related to VM (only 2 options are there)default
(right-click -> close --> power off)disk.vmdk
file (for me it's present at C:\Users\Dell\.docker\machine\machines\default\disk.vmdk
) to a place where you want to store your images that you download (basically disk.vmdk
is what will grow in size when you are using docker)default
image and goto settingsdisk.vmdk
attachment by right-clicking --> remove (that was the older path binded disk.vmdk)file
--> virtual media manager
and remove disk.vmdk
from here also (Now VM don't know if such a disk.vmdk thing exsists)default
image --> storage --> add hard disk
(this option is just above that iso image)disk.vmdk
that you have pasted somewheredocker run hello-world
I have written a very descriptive answer starting from installation because I did face some issues and so wanted to make it highly straight forward for the others.
You can delete your disk.vmdk disk (older one) from your C drive if you want to
Upvotes: 2
Reputation: 196
Create file called c:\programdata\docker\config\daemon.json with content below where e:\images is location where do you want to store all you images etc. restart docker.
{ "graph": "e:\\images" }
This Worked like a charm
Reference - https://forums.docker.com/t/where-are-images-stored/9794/11
Upvotes: 1
Reputation: 1263
I use windows 10 and Docker desktop (community) Version 2.0.0.0, I want to move vhdx file to another Drive.
Right click over Docker Desktop -> Settings then the Docker Desktop UI will open go to Advance -> Disk image location just change the path to new destination, the whole process was smooth and fast for me - it's automatically copy the vhdx file from original path to new path restart docker and all work as expected
Upvotes: 0
Reputation: 1630
I found lots of these answers were out of data, at least they did not work in my environment: win10 PRO, docker desktop community 2.0.0.3. Finally, I resolved this problem by this method:
uninstall docker
open Hyper-V manager (press WIN key and then enter "Hyper")
Change the default virtual hard disk locations in the Hyper-V settings (not on the VM settings) and confirm
install docker
check the disk image location in advanced options of docker settings
Upvotes: 0
Reputation: 731
You can move .docker
directory to another drive and create a junction point to it.
Please note that regular shortcut will not work.
For example:
Move .docker
directory from C:\Users\username
to D:\
and run:
C:\Users\username>mklink /j .docker D:\.docker
Junction created for .docker <<===>> D:\.docker
Upvotes: 63
Reputation: 1102
Simply use the VirtualBox graphic interface to relocate the file disk.vmdk
:
C:\Users\{myUsername}\.docker\machine\machines\default\disk.vmdk
into another folder, say F:\docker-image\
.VirtualBox
, select default
VM and open Settings
.Storage
, select current disk.vmdk
and release it (or delete it).Choose Virtual Hard Disk File...
and search for copied file in F:\docker-image\
File
, select Virtual Media Manager...
and release or remove old disk.vmdk
4.
, it's done!Upvotes: 22
Reputation: 1323115
Since 2015, there is now (June 2017) Hyper-V, which allows you to define where you want your VHDX
files:
See Docker for Windows 1.13.0, 2017-01-19 (stable):
VHDX file containing images and non-host mounted volumes can be moved (using “advanced” tab in the UI)
That will modify the %APPDATA%\Docker\settings.json
with a line:
"MobyVhdPathOverride":"C:\\Users\\Public\\Documents\\Hyper-V\\New folder\\MobyLinuxVM.vhdx"
See this thread for more.
Original answer
Currently 2015 , docker-machine forces the use of %USERPROFILE%
:
See libmachine/mcnutils/utils.go#L17-L25
As commented in issue 499:
In the meantime, how will users be able to specify where the
.docker/machine/*
files are stored?you can by specifying
--storage-path
on the command line or using the environment variableMACHINE_STORAGE_PATH
.
(You can see it implemented in PR 1941)
Joost Den Boer points out in the comments
Just tried '
-s <path>
' on a Mac and it seems to work fine.
What might not be obvious is that the path option goes before the command.
Running "docker-machine -s /Volumes/other/location' create --driver=virtualbox
" created a new VirtualBox image at the other location.
Upvotes: 32
Reputation: 5710
This is what worked perfectly for me on Windows 7:
Docker Toolbox will now create all the files at the location pointed at by MACHINE_STORAGE_PATH.
UPDATE:
Note that creating a new VM with the new storage path is not ideal, as the Docker Quickstart Terminal scripts don't seem to work with anything not named "default".
If you've already got a VM sitting in the C: drive, then the simplest thing to do would be to go to Oracle VirtualBox and delete the "default" VM, uninstall Docker Toolbox, delete C:\Users\<username>.docker\, and then follow the 3 steps above.
Note: uninstalling and reinstalling Docker Toolbox may not be required. But I haven't tested without it.
Update
To move Docker certificates also, set the DOCKER_CERT_PATH
variable to point to the path of the new drive. Thanks to @Nutle for the tip.
Upvotes: 61
Reputation: 9776
These answers are out of date, as of the latest release. The location is configurable in the Settings user interface.
https://github.com/docker/for-win/issues/333
Upvotes: 0
Reputation: 1723
I could not get the MACHINE_STORAGE_PATH environment variable method working. It kept complaining about missing certificates when first initialising the machine. Still on Windows 7 so have to use docker-toolbox.
I got around the issue by:
Upvotes: 8
Reputation: 31
I have had a bit of trouble with any of the solutions above but this is what worked for me:
MACHINE_STORAGE_PATH
environment variable to point to your desired
directory/folder..docker
directory..docker
folder from the Users directory.start.sh
script and added the line at the top:e.g.
export MACHINE_STORAGE_PATH=D:\\Docker
Upvotes: 3
Reputation: 1914
Put these two commands when running docker quick start terminal.
I suppose that your new location is "D:\docker" and your new machine name is "docker1"
export MACHINE_STORAGE_PATH=D:\\docker
docker-machine create --driver=virtualbox docker1
This should create a new machine with specified name in your new location.
Upvotes: 14