Docker Machine with VMware Player

The purpose of this tech article is to describe the process used to get a docker machine working on Windows 10, using VMware as the Hypervisor.

Some may think why on earth would you do this given that we now have an official Docker for Desktop release that does it all for you…and if you weren’t keen on using that, then you have the legacy Docker Toolbox that also does something similar.

Well, for a start, I didn’t want to use Hyper-V as a Hypervisor (this is the default used by the official Docker for Desktop install). I also didn’t want to use Docker ToolBox because that in itself uses Oracle Virtual Box as a Hypervisor.

I wanted to use the free (not paid) version of VMware Workstation (Player) and just “mess” with it and have some fun.

VMware Workstation Player & VMware-VIX

Configure VMWare VIX

Edit the vixwrapper-config.txt located at:

<InstallParentDir>\VMwareVIX\vixwrapper-config.txt and add the following line as shown:

# Workstation 14.0.0
ws 19 vmdb 14.0.0 Workstation-14.0.0
player 19 vmdb 14.0.0 Workstation-14.0.0
player 19 vmdb 15.1.0 Workstation-14.0.0
# latest un-versioned
ws 19 vmdb e.x.p Workstation-14.0.0
player 19 vmdb e.x.p Workstation-14.0.0

Download VMware Disk Utility

Download the VMware Virtual Disk Utility from here. Rename the file from vmdkutil-1.0.1.exe to vmware-vdiskmanager.exe and copy to target location:

<InstallParentDir>\VMwarePlayer\vmware-vdiskmanager.exe

Set Permissions

Right click on each of the following files, select the “Compatibility” tab and ensure that “Run this program as administrator” is checked.

<InstallParentDir>\VMware\VMwarePlayer\vmplayer.exe
<InstallParentDir>\VMware\VMwarePlayer\vmware-vdiskmanager.exe
<InstallParentDir>\VMwareVIX\vmrun.exe

Ensure that the VMwareVIX and VMwarePlayer paths are included in your System Path Environment Variable:

<InstallParentDir>\VMware\VMwarePlayer
<InstallParentDir>\VMwareVIX

Where <InstallParentDir> is the parent directory that contains your installation of Player & VIX. For example, if you have installed to the following directories:

C:\Apps\VMware\VMware Player
C:\Apps\VMware\VMware VIX

Then your System Path Environment would require the following entries to be added:

Download and Install Docker Binaries

docker-machine.exe/docker.exe

Update System Path

Add the directory containing the binaries to your System Path variable:

Download/Install MSYS2

Download MSYS2 from here. Choose the destination install path during the installation, for the install I’m running, the target is :

C:\Apps\msys64

Once installed, search for MSYS2 and you’ll be able to launch an MSYS command prompt.

At the MSYS command prompt, we’ll use the package manager pacman to update MSYS packages as follows:

pacman -Syu

Once the updates are done, enter the following to install make.

pacman -S base-devel gcc

The make.exe binary should now be available at C:\Apps\msys64\usr\bin. We’ll need to add this directory to our System Path environment variable.

Install SSH Binaries

I had issues getting to the docker machine using the OpenSSH binaries that are shipped with Windows 10 (optional features). The workaround was to download and install Git from https://git-scm.com/download/win.

Git includes OpenSSH binaries which worked out of the box for the setup. The installation wizard for git defaults to target directory C:\Program Files\Git. If we take a look in C:\Program Files\Git\usr\bin after the installation is complete, we’ll see several binaries and amongst them you’ll find an ssh.exe.

We’ll need to add this path (C:\Program Files\Git\usr\bin) to our System Path Environment variables. If we don’t do this, the ssh binary used for subsequent commands will default to the ssh.exe, usually located at C:\WINDOWS\System32\OpenSSH:

Also, when adding the directory C:\Program Files\Git\usr\bin to the System Path environment variable, we need to ensure that this path appears before both the C:\WINDOWS\System32 and C:\Apps\msys64\usr\bin.

Restart Powershell Console and check to ensure that the correct location is used for ssh.exe.

Installing and Configuring Golang

Download and Install GO

The simplest way of installing on Windows is by using the MSI installer from the official website. Download the latest Windows MSI installer from here. Install and follow the prompts. By default, the installer places the Go distribution in c:\Go.

The installer also adds an entry for c:\Go\bin directory in your System PATH environment variable. The default workspace is set by the installer in your User environment variables as:

GOPATH = %USERPROFILE%\go

We will need to create the above directory. The installer did not create it for us.

PS C:\> mkdir “$env:userprofile\go”

Test GO Installation

Create the directory %USERPROFILE%\go\src\hello and within this directory, create a file named hello.go with the code as shown below:

Compile/Build:

Run the hello binary:

A “hello, world” message should be displayed. This indicates that Go has been installed and configured successfully.

Download dep (Dependency Manager for GO)

Modifying the VMwareWorkstation Driver

The original source code for the driver can be found at the following git repo:

  • Download Driver Repo to Local GO Workspace:
$env:Gopath\src\github.com\pecigonzalo\docker-machine-vmwareworkstation\vmrun.go
  • Edit the following files that are now in the local repo, located at:

$env:Gopath\src\github.com\pecigonzalo\docker-machine-vmwareworkstation

vmrun.go:

$env:Gopath\src\github.com\pecigonzalo\docker-machine-vmwareworkstation\vmrun.go

workstation.go:

Change all occurrences of "nogui" to "gui"

vmx.go:

$env:Gopath\src\github.com\pecigonzalo\docker-machine-vmwareworkstation\vmx.go

vmrun.go:

$env:Gopath\src\github.com\pecigonzalo\docker-machine-vmwareworkstation\vmrun.go

Compile the Driver

From a powershell prompt, change to the local driver directory and run a make to compile.

Compile vmwareworkstation driver

After the compile is complete, the compiled binary will be located at:

Copy the driver exe over to C:\Apps\docker:

Testing the New Version of the Driver

Create Docker Machine

Now we should be able to create a docker-machine using the new compiled driver.

Using a powershell prompt (as admin):

Create Docker Machine using the New Driver

Check the Machine Status

Check Status of Docker Machine

Working with the Docker Machine

Now we can setup our docker environment shell to communicate with the new docker machine:

The command in the last line of the above output needs to be executed so that our shell environment can communicate with the docker machine host.

Hello World Docker

Final sanity check to ensure all works well. We’ll download and run the hello-world docker image to our machine and run it.

Run hello-world docker image

Learner. Interests include Cloud and Devops technologies.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store