Change Docker machine location - Windows

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. And as I commit the images the size of VM at this location bloats up. Since its Windows, cant afford the luxury of space on the C drive.

Is there any way I can change the location of the default machine?


This is what worked perfectly for me on Windows 7:

  1. Setup the MACHINE_STORAGE_PATH environment variable as the root of the location you want to use for the Docker machines/VMs, cache, etc.
  2. Install Docker Toolbox
  3. Run Docker Quickstart Terminal

Docker Toolbox will now create all the files at the location pointed at by MACHINE_STORAGE_PATH.


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.


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.

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 variable MACHINE_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.

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

Simply use the VirtualBox graphic interface to relocate the file disk.vmdk:

  1. Copy file C:\Users\{myUsername}\.docker\machine\machines\default\disk.vmdk into another folder, say F:\docker-image\.
  2. Open VirtualBox, select default VM and open Settings.
  3. Open Storage, select current disk.vmdk and release it (or delete it).
  4. Click on Choose Virtual Hard Disk File... and search for copied file in F:\docker-image\
  5. A Warning occurs: VirtualBox complains of old VM UID then go to menu File, select Virtual Media Manager... and release or remove old disk.vmdk
  6. Retry 4., it's done!
  7. If required by your environment then do the relocation also for boot2docker.iso, Snapshot Folder, Video Capture.

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.

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:

  1. Uninstalling Docker Toolbox and restarting machine
  2. Open up Administrator prompt (Find command prompt, hold shift, choose "Run As Administrator")
  3. Deleting .docker from %USERPROFILE%: rmdir /S %USERPROFILE%.docker
  4. Create folder called .docker elsewhere: mkdir a:\.docker
  5. mklink /J %USERPROFILE%.docker a:\.docker
  6. Close Admin command prompt
  7. Reinstall Docker Toolbox
  8. Use the Docker Quickstart Terminal link to bootstrap everything.
  9. Kitematic can be opened now too (though I had to choose the "Use Virtual Box" option on first error.

I have had a bit of trouble with any of the solutions above but this is what worked for me:

  • define the MACHINE_STORAGE_PATH environment variable to point to your desired directory/folder.
  • Install docker-toolbox as normal, if this works for you then fine, but for me it was still installing inside .docker directory.
  • To fix this I have then stopped and removed the default machine that was created along with .docker folder from the Users directory.
  • Edited the script and added the line at the top:


  • Run the Docker Quickstart Terminal Shortcut, which rebuilt the default machine inside the desired folder

These answers are out of date, as of the latest release. The location is configurable in the Settings user interface.

I found lots of these answers were out of data, at least they did not work in my environment: win10 PRO, docker desktop community Finally, I resolved this problem by this method:

  1. uninstall docker

  2. open Hyper-V manager (press WIN key and then enter "Hyper")

  3. Change the default virtual hard disk locations in the Hyper-V settings (not on the VM settings) and confirm

  4. install docker

  5. check the disk image location in advanced options of docker settings

Need Your Help

Select attribute depending on node's value

xml xslt xpath

It's possible I'm not asking the question correctly, so please bear with me. I need to search for a node with a given value, and return one of its attributes.