Join our Discord Server
Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 570+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 8900+ members and discord server close to 2200+ members. You can follow him on Twitter(@ajeetsraina).

Building Docker-Ready Virtual Infrastructure through Docker Machine

3 min read

“Is VM passe?” ~ this is an important debate ongoing around the globe among the CEOs, CFOs and CIOs. Most of the industry experts believe that VM is not going to die, atleast for next few decades. An emerging “Hybrid Docker + VM based solution” is gaining momentum among the Enterprise IT.

Docker_mach1  docker_machine

Docker is based on Linux containers, and cannot run Virtual machines. This limitation is crucial when testing applications within the Enterprise world, which today, run primarily on Virtualization. Usually one has to login to vSphere Client or VMware vCenter to create a virtual machine of choice, install Docker engine in the VM post installation and run the service to get started with the images and containers. Docker machine makes this a lot more easy. Just a single command and there you get docker ready VM.

Today evening I quickly grabbed a fresh Ubuntu 14.04.3 machine to try out Docker machine to connect to vSphere 6.0 to setup Docker VM in few minutes. Here is what I did:

Setting up Docker Machine

root@dell-virtual-machine:/home/dell# curl -L

https://github.com/docker/machine/releases/download/v0.5.0/docker-

machine_linux-amd64.zip >machine.zip && \
> unzip machine.zip && \
>     rm machine.zip && \
>     mv docker-machine* /usr/local/bin
% Total    % Received % Xferd  Average Speed   Time    Time     Time

Current
Dload  Upload   Total   Spent    Left  Speed
100   607    0   607    0     0    530      0 –:–:–  0:00:01 –:–:–

544
100 37.3M  100 37.3M    0     0   272k      0  0:02:20  0:02:20 –:–:–

290k
Archive:  machine.zip
inflating: docker-machine
inflating: docker-machine-driver-amazonec2
inflating: docker-machine-driver-azure
inflating: docker-machine-driver-digitalocean
inflating: docker-machine-driver-exoscale
inflating: docker-machine-driver-generic
inflating: docker-machine-driver-google
inflating: docker-machine-driver-hyperv
inflating: docker-machine-driver-none
inflating: docker-machine-driver-openstack
inflating: docker-machine-driver-rackspace
inflating: docker-machine-driver-softlayer
inflating: docker-machine-driver-virtualbox
inflating: docker-machine-driver-vmwarefusion
inflating: docker-machine-driver-vmwarevcloudair
inflating: docker-machine-driver-vmwarevsphere
root@dell-virtual-machine:/home/dell#

Verifying the Docker machine version:

#docker-machine -v
docker-machine version 0.5.0 (04cfa58)

Setting up govc tool:

#wget https://github.com/vmware/govmomi/releases/download/v0.2.0/govc_linux_amd64.gz
#gunzip govc_linux_amd64.gz
#mv govc_linux_amd64 /usr/local/bin/govc
#chmod +x /usr/local/bin/govc

Verify the govc tool:

Verify the govc setup:

root@dell-virtual-machine:~# govc
Usage of govc:
about
datacenter.create
datacenter.destroy
datastore.cp
datastore.download
datastore.info
datastore.ls
datastore.mkdir
datastore.mv
datastore.rm
datastore.upload
device.boot
device.cdrom.add
device.cdrom.eject
device.cdrom.insert
device.connect
device.disconnect
device.floppy.add
device.floppy.eject
device.floppy.insert
device.info
device.ls
device.remove
device.scsi.add
device.serial.add
device.serial.connect
device.serial.disconnect
events
fields.add
fields.ls
fields.rename
fields.rm
fields.set
guest.chmod
guest.download
guest.getenv
guest.kill
guest.ls
guest.mkdir
guest.mktemp
guest.ps
guest.rm
guest.rmdir
guest.start
guest.upload
host.add
host.autostart.add
host.autostart.configure
host.autostart.info
host.autostart.remove
host.esxcli
host.info
host.portgroup.add
host.portgroup.remove
host.vswitch.add
host.vswitch.info
host.vswitch.remove
import.ova
import.ovf
import.spec
import.vmdk
license.add
license.list
license.remove
ls
pool.change
pool.create
pool.destroy
pool.info
version
vm.change
vm.create
vm.destroy
vm.disk.attach
vm.disk.create
vm.info
vm.ip
vm.network.add
vm.network.change
vm.power
vm.question
vm.vnc

That’s it. I am all ready to create VM in my vSphere 6.0 box with Docker ready..

#docker-machine -D create -d vmwarevsphere –vmwarevsphere-vcenter
“10.94.214.184” –vmwarevsphere-cpu-count “2”  –vmwarevsphere-datacenter “HA
proxy” –vmwarevsphere-datastore “datastore1”  –vmwarevsphere-memory-size
“2048” –vmwarevsphere-compute-ip “10.94.214.184” –vmwarevsphere-username
“root” –vmwarevsphere-password “password” –vmwarevsphere-network=”VM
Network” docker-vm4
Docker Machine Version: 0.5.0 (04cfa58)
Found binary path at /usr/local/bin/docker-machine-driver-vmwarevsphere
Launching plugin server for driver vmwarevsphere
Plugin server listening at address 127.0.0.1:40977
() Calling RpcServerDriver.GetVersion
Using API Version 1
() Calling RpcServerDriver.SetConfigRaw
() Calling RpcServerDriver.GetMachineName
(flag-lookup) Calling RpcServerDriver.GetCreateFlags
Making call to close connection to plugin binary
Making call to close driver server
(flag-lookup) Calling RpcServerDriver.Close
Successfully made call to close driver server
Found binary path at /usr/local/bin/docker-machine-driver-vmwarevsphere
Launching plugin server for driver vmwarevsphere
Plugin server listening at address 127.0.0.1:42447
() Calling RpcServerDriver.GetVersion
Using API Version 1
() Calling RpcServerDriver.SetConfigRaw
() Calling RpcServerDriver.GetMachineName
(docker-vm4) Calling RpcServerDriver.GetMachineName
(docker-vm4) Calling RpcServerDriver.DriverName
(docker-vm4) Calling RpcServerDriver.GetCreateFlags
(docker-vm4) Calling RpcServerDriver.SetConfigFromFlags
Running pre-create checks…
(docker-vm4) Calling RpcServerDriver.PreCreateCheck
(docker-vm4) Calling RpcServerDriver.GetConfigRaw
(docker-vm4) Calling RpcServerDriver.GetConfigRaw
Creating machine…
(docker-vm4) Calling RpcServerDriver.Create
(docker-vm4) OUT | Generating SSH Keypair…
(docker-vm4) OUT | Uploading Boot2docker ISO …
(docker-vm4) DBG | govcOutErr executing: govc datastore.ls —
u=root:ca@10.94.214.184 –k=true –ds=datastore1 –dc=HA proxy docker-vm4
(docker-vm4) DBG | govcOutErr executing: govc datastore.mkdir —
u=root:ca@10.94.214.184 –k=true –ds=datastore1 –dc=HA proxy docker-vm4
(docker-vm4) OUT | Creating directory docker-vm4 on datastore datastore1 of
vCenter 10.94.214.184..

Hurray !!! You just got a Docker-ready VM configured on your vSphere box.
Docker Machine just does it so well.

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 570+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 8900+ members and discord server close to 2200+ members. You can follow him on Twitter(@ajeetsraina).
Join our Discord Server