Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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?

like image 616
shrivb Avatar asked Nov 26 '15 07:11

shrivb


People also ask

How do I move my Docker desktop to another drive?

In this approach, we will simply stop the Docker Desktop, move the space-eating directories to another drive having sufficient space, and finally creating symlinks. Step 1 - Stop Docker Desktop. Step 2 - Relocate the existing directories %USERPROFILE%\AppData\Local\Docker and C:\ProgramData\Docker to new directories.


2 Answers

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.

like image 109
Rajesh J Advani Avatar answered Sep 29 '22 19:09

Rajesh J Advani


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 
like image 34
vlado Avatar answered Sep 29 '22 19:09

vlado