How to run a Docker Swarm Cluster on vSphere with Photon

At this point you have been playing around with containers on one VM but you want to take it a step further and orchestrate container deployments across multiple VM’s. In this guide I will show you the fastest way to get up and running with a swarm cluster on vSphere using Project Photon as a container host.


Start by downloading the Photon ISO from here:

Next, install Photon on a vSphere VM by following this guide

For this exercise we will need a minimum of 2 Photon VM’s and a workstation running docker.

Please NOTE: if you plan on using vCenter to clone your Photon VM you will need to regenerate the Docker ID on each cloned VM. To do this:

1.Login to the Photon VM and remove the key.json file by typeing rm /etc/docker/key.json and press enter

2.Reboot the Photon VM and login and type Docker info and press enter. Verify the ID on both VM’s is different.

Power on both your docker VM’s and login as root and stop Docker

systemctl stop docker

Now start the docker daemon with the following: docker -H tcp://ipaddress:2375 -d &

You should see the following when it is running correctly

Make sure to do the same on your additional nodes, make sure you use the IP address of the Photon node your on to start the Docker Deamon

Now log into your workstation and run the following command to create your cluster

docker run --rm swarm create

Notice the last line after the command completes, this is your cluster ID. Copy and past that to a safe place. You will need it for the rest of the setup.

Now on your workstation still, enter the following for each node to add them to the cluster

docker run -d swarm join --addr=node_ip:2375 token://cluster_id

Now, on your workstation still, start the cluster manager with the following command

docker run -d -p 8333:2375 swarm manage token://cluster_id

Now that the cluster manager is running lets see if our nodes are ready by typing the following and pressing enter

docker -H tcp://yourworkstationIP:8333 info

Now that the cluster is up lets run a container, type the following and press enter

docker -H tcp://yourworkstationIP:8333 run -d -p 80:80 vmwarecna/nginx

Now type the following to see the status of the container and which Photon node it’s running on

docker -H tcp://yourworkstationIP:8333 ps

Open a web browser to the node listed and let the magic begin!

Setup a host affinity rule so your nodes are never on the same host for extra credit!

Remember sharing is caring!

One Reply to “How to run a Docker Swarm Cluster on vSphere with Photon”

  1. 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.