Wednesday, 30 March 2016

Location of VM when using VMWare & Docker on windows

In my previous post I covered how to get Docker working on windows using VMWare workstation rather than VirtualBox.

One problem I ran into is that by default Docker will create the VM for the host OS in the users directory which usually resides on the C drive.

I try not to have my VM’s on C as I tend to keep that for my main OS and so I wanted to find a way to move where the VM was created.

First method I found for doing this involved me manually moving the vmdk by opening the VM in workstation after it was running, stopping Docker, moving the vmdk and editing the VM details in workstation to set it to the new location.  Whilst this worked it is a complete pain and so I dropped that approach and looked for alternatives.

I then found the create option--storage-path which allows you to specify where the VM should be created, this worked but again I didn’t want to have to specify the location every time, good for flexibility but if I forgot to use it then the VM would end up being created on the C drive.

Then I found there is an environment variable that Docker looks for named MACHINE_STORAGE_PATH which will be used as the root folder when Docker creates the VM it will use as the Host OS.

So on my machine I set it to F:\Docker and then Docker created all the necessary folders (cache, certs, machines) under this folder and the individual VM’s are created in machines folder.

Remember you will need to restart your command/console window once you set the environment variable or it won’t take affect.

No comments:

Post a Comment