If you haven't heard, it's 2016 and Microsoft Azure has awesome support for Linux and Docker but what you might not know is that there's a bit of pitfall when using Docker on an Azure VM.
For the most part, using Docker on Azure is the same as in other environments. However there are a couple things you should be aware of in the Azure environment that can save you some headache after you deploy your Docker apps to Azure VMs.
Azure VM Disk Space
Unlike AWS and other cloud providers, when you're creating a VM in the Azure portal (via the wizard), it doesn't automatically attach a data disk but gives you a 30GB 'OS Disk'. These disk are backed by 'Azure Storage' (the S3 equivalent on Azure) and it isn't immediately obvious you should attach one.
The OS Disk
An Azure OS Disk will give you somewhere around 4000 - 5000 I/O operations per second (IOps) when backed by premium storage (source) and approximately 500 IOps for a regular storage backed OS Disk. 500 IOps works fine for downloading and building docker images, so don't spring on the premium storage unless you actually need it for your running apps.
The OS Disk will be the default place Docker stores its image files, which can quickly grow past the 30GB allocated after a short while of deploying images. You'll likely run out of space in about a month or so depending on how often you build images.
Attaching a Docker Volume
It is good practice to attach a volume strictly to store Docker images. 500 - 1TB (standard-storage backed) is a safe amount which will allow thousands of image builds without running the risk of blowing through your storage.
To attach a new
ext4 volume to an existing Linux VM follow the Microsoft-provided best-practice guide on attaching a new VM for your specific distro.
Configuring the Docker Demon
With your shiny new Docker disk attached and mounted (make sure in the guide above you setup your VM to auto-mount the disk) add to the
DOCKER_OPTS the line in your Docker configuration file to store the images to the data disk. That file can be found at:
- /etc/default/docker (Ubuntu/Debian)
- /etc/sysconfig/docker (Fedora/CentOS/Redhat)
DOCKER_OPTS="[existing docker options] -g /path/to/mounted/data/disk/dockerimages"
Now restart your Docker demon for changes to take effect immediately:
# ubuntu/debian sudo service docker stop sudo service docker start # fedora/redhat/centos sudo systemctl stop docker sudo systemctl start docker
Caution Any containers you had running previously won't start until you rebuild the images, since the Docker Demon won't see the images you've already built.
Now, you shouldn't have to worry about disk space choking up your Docker apps.