Docker as a Service in vRA/vCAC part 2 – InstallPullandRun

So you want to offer your developers an Infrastructure as a service (IaaS) that is beyond just traditional Physical, virtual or cloud servers right? Well look no further, vRealize Automation can quickly and easily be extended to accommodate containers as an IaaS offering . In this guide I will show you how you can offer containers as a service through the vRA portal while still maintaining all the rich automation, reclamation, policy and governance that vRA is famous for. Add in NSX and you can also provision load balancers and networks for your containers! So what are you waiting for? Let’s get going!

Watch a short video of this integration.

Docker As a Service Part 1

NOTE: in part 1 we used the Linux Guest agent. While you can build on that blueprint with this guide, it is not required. This guide will also install and start the docker service so the guest agent is not needed.


Docker as a Service vRA/vCAC Extension v.1.0

Revisons: None

Pre-Reqs you will need in place for this solution:

  • vCAC 6.0, 6.1 or vRA 6.2 installed and configured (This will probably work with vCAC 5.2 but I have not tested)
  • vRA/vCAC configure to run vCO workflows at machine states. See my guide here.
  • RHEL or CENTOS 6.6 or higher blueprint setup to provision from the vRA or vCAC portal.
  • Provisioned VM’s need to have access to the internet to pull repository packages and docker images.
  • An NFS server with a mountable script directory available for you to run scripts and install software from. See this guide here.
  • A quite place to work for a few hours where you will not be interrupted.


  • If you need the docker images to download faster or your VM’s don’t have access to the internet, you may consider a local Docker registry. Follow my guide here. (NOTE you will need to modify the Docker scripts in this guide to work with a local docker registry)

Power on your Linux template and login as root or sudo to root and create directory on the root file system named repo. This is where you will mount your NFS share to.


Next, create a file named using the vi editor with the following content and save it.

mount -t nfs $1:$2 /repo &>/repomount.log

Make the executable by typing the following then pressing enter

chmod u+x

Now shutdown your template. Remember, if you are using Linked clones you will also need to take a new snapshot in vCenter Client and then run an inventory scan in vCAC and update the blueprint to point to the new snapshot.


Now let’s create the script that we will run to install Docker. Pull the Docker image and start the container. Using the vi editor create the script


Press the i key to change to insert mode and enter the following lines then press escape and then Hold Shift and press ZZ to save it.

yum -y install epel-release 
yum -y install docker-io
service docker start >/dockerstarted.log 2>&1
chkconfig docker on 
sleep 30
$1 >/dockerpull.log 2>&1
$2 >/dockerrun.log 2>&1

Now make the script executable with the following.

chmod u+x

The above script is first installing the Extras packages, then it installs docker, next it starts the docker service then adds it to start at boot. The next step is a sleep for 30 seconds to make sure docker is started properly. Then I pass the Docker run string and Docker pull string from the user input in vRA to pull and run the container.

Now we need to import the workflow package into your vCO instance. NOTE: if you have not already configured vRA and vCO together this guide will not work.

Download My Package here >>.org.vmtocloud.vravcac.dockerinstallpullandrun

The file is in ZIp format. Unzip the file first and then log into the vRO client and import the package like so.


This workflow uses the Guest Script Manager Package created by @cdecanini_ over at

Under the VMtocloud folder you should see a new workflow named DockerInstallPullandRun


Edit this workflow and go to the General tab. You will need to edit the vmUsername and vmPassword so the workflow can access the newly provisioned VM.


Now save and close the workflow


Now we need the workflow ID so we can create the Build Profile in vRA to call this workflow as part of the provisioning process. Copy the ID to the clipboard.


Now login to the vRA\vCAC portal and navigate to the Infrastructure tab, then Blueprints and build profiles and create the following build profile. Notice the DockerPull and DockerRun Prompt the user. Click OK to save the build profile.

docker.pullandrun.script /repo/
ExternalWFStubs.MachineProvisioned This is the ID of the vCO workflow you copied to your clipboard. 
repo.path The path to your NFS share
repo.server The NFS server
VMware.VirtualCenter.OperatingSystem rhel6_64Guest

Now attach the Build profile to you RHEL/CENTOS 6.6 template and verify the properties are correct.


Now fire off a new request and provide the Docker Pull and Run commands you want. I provided an easy ones below.

docker pull vmtocloud/myblog
docker run -d -p 80:80 vmtocloud/myblog

After several minutes or up to 20 minutes depending on your network speed, the machine should finish provisioning.


Open a web browser to the new servers address and let the magic begin!


Some helpful troubleshooting tips. If the vRO workflow does not run this integration will not work. Check vRO and vRA for status. in vRO watch to see the workflow runs and monitor status.


Also watch the following screen in vRA/vCAC to check the status of the VM provisioning. The vRO workflow should run in Machine Provisioned stage


Enjoy, I will also post a modified version of this with a local docker registry soon.

Remember sharing is caring!

2 Replies to “Docker as a Service in vRA/vCAC part 2 – InstallPullandRun”

  1. Pingback: vRealize your containers with VMware |

  2. Pingback: Containers for the vSphere Admin |

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.