Change Docker machine location - Windows Change Docker machine location - Windows docker docker

Change Docker machine location - Windows


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.

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.


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:\.dockerJunction created for .docker <<===>> D:\.docker


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"

https://cdn-enterprise.discourse.org/docker/uploads/default/optimized/2X/6/6193445cf15811ce18317c727af258adb2d16c9d_1_690x447.jpg

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.