Azure & Docker : Shared storage anyone?

Introduction

Persistent storage is a though cookie for Docker… We’ve seen things like Flocker, Convoy, … Today, we’ll do a very rough (and experimental!) setup with an Azure storage account (via Azure File Share) as shared storage. How would such a design look?

Docker-Azure-File-Share

Setup Azure File Share

So how to setup an Azure file share?

A) startup azure powershell and authenticate

Add-AzureAccount

B) create a context for account and key

$ctx=New-AzureStorageContext storageaccountname mystorageaccountkey==

C) create a new share

$s = New-AzureStorageShare docker-Context $ctx

Source : https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-files/

 

Connect to Azure File Share

Let’s create the local mountpoint & link it to our file share…

root@kvaesdocker02:~# mkdir -p /azure/storageaccountname
root@kvaesdocker02:~# mount -t cifs //storageaccountname.file.core.windows.net/docker /azure/storageaccountname-o vers=3.0,user=storageaccountname,password=mystorageaccountkey==,dir_mode=0777,file_mode=0777
root@kvaesdocker02:~# cd /azure/storageaccountname/
root@kvaesdocker02:/azure/storageaccountname# ls -la
total 1536000
-rwxrwxrwx 1 root root 524288000 Jan 13 14:27 testfile
-rwxrwxrwx 1 root root 524288000 Jan 13 14:32 testfileA
-rwxrwxrwx 1 root root 524288000 Jan 13 14:32 testfileB

and on the other node the same thing…

root@kvaesdocker01:/azure/storageaccountname# ls -la
total 1536000
-rwxrwxrwx 1 root root 524288000 Jan 13 14:27 testfile
-rwxrwxrwx 1 root root 524288000 Jan 13 14:32 testfileA
-rwxrwxrwx 1 root root 524288000 Jan 13 14:32 testfileB

Source : https://azure.microsoft.com/en-us/documentation/articles/storage-how-to-use-files-linux/

 

Azure File Storage Limits

The most important limitation to me is that you cannot set any ACLs. Apart from that, check out the Azure Limits page!

 

What about performance?

So we’ll do some basic performance tests so we know what to expect…

root@kvaesdocker01:/azure/mystorageaccount# dd if=/dev/zero of=./testfile bs=10M count=1 oflag=direct
1+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 0.513219 s, 20.4 MB/s
root@kvaesdocker01:/azure/mystorageaccount# dd if=/dev/zero of=./testfile bs=10M count=1 oflag=direct
1+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 0.562699 s, 18.6 MB/s
root@kvaesdocker01:/azure/mystorageaccount# dd if=/dev/zero of=./testfile bs=10M count=1 oflag=direct
1+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 0.42083 s, 24.9 MB/s
root@kvaesdocker01:/azure/mystorageaccount# dd if=/dev/zero of=./testfile bs=100M count=1 oflag=direct
1+0 records in
1+0 records out
104857600 bytes (105 MB) copied, 3.67266 s, 28.6 MB/s
root@kvaesdocker01:/azure/mystorageaccount# dd if=/dev/zero of=./testfile bs=100M count=1 oflag=direct
1+0 records in
1+0 records out
104857600 bytes (105 MB) copied, 3.7312 s, 28.1 MB/s
root@kvaesdocker01:/azure/mystorageaccount# dd if=/dev/zero of=./testfile bs=500M count=1 oflag=direct
1+0 records in
1+0 records out
524288000 bytes (524 MB) copied, 17.5481 s, 29.9 MB/s
root@kvaesdocker01:/azure/mystorageaccount# dd if=/dev/zero of=./testfile bs=500M count=1 oflag=direct
1+0 records in
1+0 records out
524288000 bytes (524 MB) copied, 18.5576 s, 28.3 MB/s
root@kvaesdocker01:/azure/mystorageaccount# cd ../
root@kvaesdocker01:/azure# dd if=/dev/zero of=./testfile bs=500M count=1 oflag=direct
1+0 records in
1+0 records out
524288000 bytes (524 MB) copied, 17.4357 s, 30.1 MB/s
root@kvaesdocker01:/azure# dd if=/dev/zero of=./testfile bs=500M count=1 oflag=direct
1+0 records in
1+0 records out
524288000 bytes (524 MB) copied, 23.0896 s, 22.7 MB/s
root@kvaesdocker01:/azure# dd if=/dev/zero of=./testfile bs=500M count=1 oflag=direct
1+0 records in
1+0 records out
524288000 bytes (524 MB) copied, 19.9195 s, 26.3 MB/s
root@kvaesdocker01:/azure# dd if=/dev/zero of=./testfile bs=500M count=1 oflag=direct
1+0 records in
1+0 records out
524288000 bytes (524 MB) copied, 24.603 s, 21.3 MB/s

This gives about 20-25MB/s for both the local system disk & the file share. So where this is shared, do not expect great performance with this setup!

 

What… no NFS?!?

I can relate… Please help upvoting the NFS feature on the Microsoft User Voice!

 

Now let’s do a small test!

So we start off with our two hosts…

2016-01-13 16_48_56-Start

Now let’s create a service using “bitnami/apache” and we’ll map the local volume to the htdocs root.

2016-01-13 17_32_50-Rancher

The container started, and we can see the default files from our host / file share… And we’ll add a file from our second host.

2016-01-13 17_34_58-

We can see that file from our first host and we’ll add one from that one…

2016-01-13 17_31_11-Start

And we can see that one from our container too!

2016-01-13 17_31_58-Rancher

Even when the container switches hosts…

 

TL;DR

  • We can mount an Azure file share from Linux
  • The mount can be accessed/written by multiple nodes
  • The mounted volume can be mapped towards directories within a container
  • This method can facilitate data persistence
  • Be aware the this is experimental & not high performant
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s