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.

Tuesday, 29 March 2016

Docker using VMWare workstation on windows

I’ve wanted to explore Docker for a while now being on windows meant I’d need to use VirtualBox which I didn’t want to do since I already have VMWare Workstation installed.

After a bit of a google I found that there was a driver to use VMWare with docker but no posts describing how to use it.  With a bit of trial and error I got it working and thought I’d share how to do it here.

How to..

Before you start you need to be on Windows 7 or above and have VMWare workstation already installed.

First install Docker machine for windows (you can get it from here), this will install all the normal programs needed to run docker.

Next you want to get the VMWare workstation driver from here, its an exe but you don’t run it you just need to copy the driver into the folder where you installed Docker Machine (usually C:\Program Files\Docker Toolbox).

At this point you’ll be able to run a create command which will build a Docker instance but you won’t be able to talk to the container.  The reason for this is the network adapters that VirtualBox installs will stop Docker talking to the VMWare virtual machine.

To be happy that its all working you can simply disable the network adapters and then any container you create should work.  At this point you can either leave as is or uninstall VirtualBox.

One side effect of this is that you won’t be able to use Kitematic since it only works with VirtualBox on windows.

Is this useful?

Even as I write this post I know that the Docker for Windows beta is coming out but that only uses Hyper-V at the moment.  Docker have said that you’ll still be able to use Docker Machine after Docker for Windows arrives and if you want to use VMWare that this may still be the best option for you.