VMware recently released a Beta version of a plugin for Docker volumes. I was curious to see if it also works on Photon Platform. Well it does! In this guide I will walk you through setting it up and then we will run my favorite app in a container to show you how it works. In this guide I will be using Photon Controller .8 with Photon OS 1.0 and ESXi 6 hosts.
Pre-Reqs
- Photon Controller .8 or newer installed and configured see guide here.
- ESXi hosts running 6.0, 6.0 u1, 6.0 u2
- Photon OS 1.0 OVA downloaded and deployed from here.
- The vib for ESXi from here.
- The Docker Volume Driver RPM from here.
- At least one Photon OS deployed from Photon Controller See guide here.
- Internet access from the Photon OS VM’s to the internet or DockerHub.
- A quite place where you will no be interrupted
First, let’s enable the ESXi hosts, upload the VIB you downloaded and install it with the following command, repeat on all hosts you plan to use the VMware Volume driver on. Currently the Beta release does not support VMotioning the VM to another host.
NOTE: Be sure to point to the path and name of the vib you downloaded.
esxcli software vib install -v /tmp/vmware-esx-vmdkops-1.0.beta.vib --force
If you have not done so, deploy a new Photon VM from the Photon Controller command line. Upload the RPM you downloaded to /tmp and then open an SSH session. Now let’s install the driver on Photon OS using the RPM but first stop the docker service
systemctl stop docker
Now let’s install the RPM you downloaded earlier, upload it to the Photon Server and type the following
rpm -ivh /tmp/docker-volume-vsphere-1.0.beta-1.x86_64.rpm
systectl start docker
Now were ready to test an app, we are going to be using two containers, WordPress and a MariaDB container so we will need a network, create a network with the following command
docker network create wordpress-tier
docker volume create --name mariadb_data --driver=vmdk -o size=5gb
Now go to the Embedded host client of the ESXi host where the Photon VM is running and take a look at the datastore that the VM is on and you will see a new folder with the volume as a VMDK.
Cool hugh?
Now let’s go back to the docker client and see how the developer would see their volumes by typing the following
docker run -d --name mariadb \
--net wordpress-tier \
--volume mariadb_data:/bitnami/mariadb \
bitnami/mariadb:latest
docker volume create --name wordpress_data --driver=vmdk -o size=5gb
docker volume create --name apache_data --driver=vmdk -o size=5gb
docker run -d --name wordpress -p 80:80 -p 443:443 \
--net wordpress-tier \
--volume wordpress_data:/bitnami/wordpress \
--volume apache_data:/bitnami/apache \
bitnami/wordpress:latest
Now login to the wordpress site and create a new post http://ipofyourPhotonOS/wp-login.php
Login: user
Password: bitnami
docker stop wordpress mariadb
You will also notice your wordpress site is down, now let’s delete the containers with the following command
docker rm mariadb wordpress
Shutdown the VM with the following command
Launch a new Photon VM from the Photon Controller Command line and power it on. You will also need to install the Docker Volume Driver again and start Docker using the instructions above. Once you have the driver installed and docker started run the following command: NOTE: this is assuming the VM is on the same ESXi host or you are using some sort of shared storage on the hosts.
Notice you can still see your volumes, now let’s create that network again with the following command:
docker network create wordpress-tier
Now let’s launch the MariaDB container and attach it to the existing volume with the following command:
docker run -d --name mariadb \
--net wordpress-tier \
--volume mariadb_data:/bitnami/mariadb \
bitnami/mariadb:latest
Now launch the WordPress container and attach to the existing volumes with the following command:
docker run -d --name wordpress -p 80:80 -p 443:443 \
--net wordpress-tier \
--volume wordpress_data:/bitnami/wordpress \
--volume apache_data:/bitnami/apache \
bitnami/wordpress:latest