In previous posts we have looked at using a “cluster” for deploying docker swarm on top of photon controller. Of course, deploying docker swarm via the cluster management construct may not be what some customers wish to do, so now we have full support for “docker-machine” on photon controller as well. This will allow you to create your own docker swarm clusters using instructions provided by Docker. In this post, we will look at getting you started with building the docker-machine driver plugin, setting up Photon Controller, and then the setup needed to allow the deploying of docker-machine on Photon Controller.

You can find the software and additional information on github.

*** Please note that at the time of writing, Photon Controller is still not GA ***

Step 1 – Prep Ubuntu

In this scenario, I am using Ubuntu VM. There are the commands to prep that distro for the docker-machine driver plugin for photon controller:

apt-get update apt-get install docker.io => install Docker apt-get install golang => Install the GO programming language apt-get install genisoimage => needed for mkisofs

Step 2 – Build docker-machine and the docker-machine driver plugin

Download and build the photon controller plugin for docker-machine. You can do this by first setting the environment variable GOPATH, and then running “go get github.com/vmware/docker-machine-photon-controller”. I simply set GOPATH to a newly created directory called /GO, cd /GO and then running the go get.

Once the code is downloaded, change directory to the “src/github.com/vmware/docker-machine-photon-contoller” directory and then run the “make build” command. This creates the binary in the bin directory. Finally run the command “make install” which copies the binary to the /usr/local/bin directory.

Next step is to build the docker-machine binary. The source has been pulled down earlier with the go get command, but you will need to change directory to “src/github.com/docker/machine” and run “make build” and “make install”.

Note that you do not run the docker-machine-photon-controller binary directly. It is called when the “docker-machine create” command with -d option is run, which you will see shortly. Verify that the “docker-machine” is working by running it and getting the “usage” output.

Step 3 – Get Photon Controller ready

You have to do the usual stuff with Photon Controller, such as creating a tenant, project, image, and so on. I won’t repeat the steps here as they have been covered in multiple posts already, such as this one here on Docker Swarm. The image I am using in this example is Debian 8.2 which you can get from the bintray here. There are some additional steps required for docker-machine, and these are the requirement to have disk and VM flavors. These are the flavors I created:

> photon flavor create -k vm -n DockerFlavor -c "vm 1.0 COUNT, vm.flavor.core-100 1.0 COUNT, vm.cpu 1.0 COUNT, vm.memory 2.0 GB, vm.cost 1.0 COUNT" > photon flavor create -k ephemeral-disk -n DockerDiskFlavor -c "ephemeral-disk 1.0 COUNT, ephemeral-disk.flavor.core-100 1.0 COUNT, ephemeral-disk.cost 1.0 COUNT"

Note the names of the flavors, as we will need to reference these shortly. OK. We’re now ready to create a docker-machine on this photon controller setup.

Step 4 – Setup ENV, get RSA key, create cloud-init.iso

Back on my Ubuntu VM, I need to set a bunch of environment variables that reflect my Photon Controller config. These are what I need to set up:

export PHOTON_DISK_FLAVOR=DockerDiskFlavor export PHOTON_VM_FLAVOR=DockerFlavor export PHOTON_PROJECT=a1b993e6-3838-43f7-b4fa-3870cdc0ea76 export PHOTON_ENDPOINT=http://10.27.44.34 export PHOTON_IMAGE=21a0cbf6-5a03-4d2c-919c-ccf6ea9c432b