How to use the Docker Volume Driver with Photon Platform

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.

Dockervols

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.

DockerVolumeDriverVibInstall
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

Now start docker again with the following

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

Now let’s create our first VMDK backed volume for our MariaDB container with the following

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.

DockevolsVMware

Cool hugh?

Now let’s go back to the docker client and see how the developer would see their volumes by typing the following

Now let’s launch the MariaDB container and map it to the volume with the following command

docker run -d --name mariadb \
  --net wordpress-tier \
  --volume mariadb_data:/bitnami/mariadb \
  bitnami/mariadb:latest

Now let’s create our volume for WordPress data with the following

docker volume create --name wordpress_data --driver=vmdk -o size=5gb

Now create the Volume for Apache data with the following command

docker volume create --name apache_data --driver=vmdk -o size=5gb

Now let’s start our wordpress container and map it to those 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

Now login to the wordpress site and create a new post http://ipofyourPhotonOS/wp-login.php

Login: user

Password: bitnami

Create a new post!

Create the following post and click publish!

create-the-following-post-and-click-publish--

Stop both the wordpress and mariadb containers with the following command

docker stop wordpress mariadb

You will also notice your wordpress site is down, now let’s delete the containers with the following command

Screen Shot 2016-06-28 at 6.11.47 PM
docker rm mariadb wordpress

Shutdown the VM with the following command

Screen Shot 2016-06-28 at 6.13.06 PM

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.

Screen Shot 2016-06-28 at 6.19.57 PM

Notice you can still see your volumes, now let’s create that network again with the following command:

Screen Shot 2016-06-28 at 6.22.36 PM

docker network create wordpress-tier

Now let’s launch the MariaDB container and attach it to the existing volume with the following command:

Screen Shot 2016-06-28 at 6.29.10 PM

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:

Screen Shot 2016-06-28 at 6.34.03 PM

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

Open a browser again to your wordpress site http://ipofNewPhotonOS

open-a-browser-again-to-your-wordpress-site-http---ipofphotonos

Enjoy using Docker Volumes on Photon Platform!

Remember, sharing is caring ->Tweet about this on Twitter
Twitter
0Share on Facebook
Facebook
0Share on LinkedIn
Linkedin
Share on Google+
Google+
0Email this to someone
email

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.