How to use azure file storage volume plugin with Docker
In this article, we will see how to use azure file storage volume plugin with Docker.
Before we start, it would be useful to know that what Docker plugins are. Docker plugins extends the Docker capabilities to use external services available for storage and networking. There are several volumes and networking plugins are out there. In this article, we will see how to use azure file storage Docker volume plugin to deal with persisting storage with Docker.
This plugin enables you to use the same storage accounts across different Docker hosts or in a swarm cluster. Now let's see it in action. I am going to login to a Linux VM provision in azure where I already installed and configured Docker. Here are two ways of provision Ubuntu Machine on Azure using PowerShell and Docker Machine.
I have a couple of Docker images and no directory.
Use a script to get Docker volume driver on my machine that you can find out my github repository here. I grabbed this repository by running git clone in the terminal. I should also enable the execution permission to be able to run the script on Linux VM:
chmod +x AzureFileStorageVolumePlugin.sh
The only thing you need to pass to the script is the name of the file containing your azure storage account access key. So, I will create the file with an editor. The first thing you need to put here is the name of the azure storage account which you can get from azure portal =>azure storage account => click on Access keys and then grab the access key of your storage account.
I save the file with name of azureStorageKey.
Let’s run the script and we will have the volume driver up and running.
Now to use this let’s create a Docker volume with azure file volume driver with any name such as azure_volume as below:
sudo docker volume create --name azure_volume -d azurefile -o share=docker azure_volume
Next want a container against this volume that we just created.
docker run -i -t -v azure_volume:/data ubuntu
echo "azure file storage test" > afs_test.txt
Now browse to your azure storage account and select the volume service that we just created and
here is the file we created from our running container on azure file storage.
Number of Views:2998