In this article I want describe how to prepare environment for deploy container by one click from catalog
First step is to create VM on which we start docker engine. I’ve decided to use PhotonOS which is delivered by VMware in ova file. So I’ve deploy VM and change it to template. After Data collection we are able to use it in design
To prepare this VM for work with docker I decided to customize it from vRO. In this case I’ve put custom property
After this specific setup, we are able to use Event Subscription which run our vRO workflow
My workflow is a very simple and has only two element
In Get-VM-From-Text, I have Scriptable task to collect payload and convert VM name to VM object
The second Scriptable Task is setup docker on that specific VM
var host = vmName.sdkConnection;
var guestOperationsManager = host.guestOperationsManager;
var guestAuth = new VcNamePasswordAuthentication();
guestAuth.username = "root";
guestAuth.password = "QSCcsq123!@#";
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/systemctl";
guestProgramSpec.arguments = "stop docker";
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/mkdir";
guestProgramSpec.arguments = "/etc/systemd/system/docker.service.d/";
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/echo";
guestProgramSpec.arguments = '"\[Service\]" >> /etc/systemd/system/docker.service.d/docker.conf';
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/echo";
guestProgramSpec.arguments = '"ExecStart=" >> /etc/systemd/system/docker.service.d/docker.conf';
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/echo";
guestProgramSpec.arguments = '"ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock" >> /etc/systemd/system/docker.service.d/docker.conf';
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/systemctl";
guestProgramSpec.arguments = 'stop iptables';
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/systemctl";
guestProgramSpec.arguments = 'disable iptables';
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/systemctl";
guestProgramSpec.arguments = 'deamon-reload';
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
var guestProgramSpec = new VcGuestProgramSpec();
guestProgramSpec.programPath = "/bin/systemctl";
guestProgramSpec.arguments = 'restart docker';
var processManager = guestOperationsManager.processManager;
result = processManager.startProgramInGuest(vmName , guestAuth , guestProgramSpec);
So now we are able to deploy our Photon
When deployment is finished we have IP address which will be used with specific port assigned to docker in script tcp://0.0.0.0:2375
So now we are able to configure docker cluster
Click on New Cluster and provide all details
On that cluster we are able to run container from vRA web page or we can create container template for using it multiple times
After create it as a template we can push it to Blueprint
After follow the procedure to add new element to catalog we can use this WordPress blueprint as many times as we need
so let’s request one container with WordPress
When provision is finished then we have access to our container on specific IP and port
And that’s it we can provide container element in catalog without connecting to docker console