Docker has achieved rapid and widespread adoption since its inception a little over five years ago. Though container technology has been around for some time, Docker builds a coherent ecosystem around the low-level technology. This makes it easier for software developers to package, test, and deploy new applications and services. But nice as all that is, Docker has persistent storage demands similar to Kubernetes storage.
These storage demands an additional layer of complexity to Docker deployment, as the requirements for block-level and shared file storage, high availability, and the flexibility to rapidly create test copies of data start to become more important.
In this Docker volume tutorial, we will look at the way in which storage volumes can be provisioned for Docker containers using NetApp Trident and Cloud Volumes ONTAP, show you how they can be used with Kubernetes, and explain which benefits they provide to software developers and DevOps workflows.
The recommended way to provision persistent storage for Docker containers is through Docker volumes, which are created and managed independently of Docker containers. Docker volumes act as an abstraction layer between the containers that require storage and the underlying details of how that storage is provisioned. Volumes are created and managed using native Docker commands, which helps to maintain a consistent interface for all Docker administration operations.
Docker volumes can be provisioned using local, block-level storage or Docker file system, such as NFS. In either case, the storage must already be accessible to the Docker host machine. For example, to use Amazon EBS, a disk of the right size must be pre-allocated and assigned to the Amazon EC2 instance that will host the container. Moving the storage to a different host, scaling out performance and capacity, creating data backups, monitoring the disk performance, and performing all other storage related operations that are vital for supporting a production environment must be carried out manually.
Cloud Volumes ONTAP is NetApp’s enterprise-grade solution for data storage management in the cloud, delivering flexible, scalable and fault-tolerant AWS and Azure services. Using NetApp Trident, NetApp’s provisioner for containerized applications, Docker hosts are able to integrate with Cloud Volumes ONTAP, or any ONTAP, SolidFire or E-Series storage platform, and take advantage of features such as snapshots, volume cloning, storage space efficiencies, and much more.
Trident uses the Docker plugin architecture to provide integration between Docker hosts to NetApp storage services. By issuing normal Docker volume commands, Docker hosts can automatically provision new NFS or block-level iSCSI storage from Cloud Volumes ONTAP. This brings uniformity to the way storage is provisioned without introducing a suite of new client tools, and enables containerized applications to benefit transparently from NetApp storage features.
Each volume provisioned through Trident can have an associated snapshot policy, which defines the frequency at which point-in-time backups are be created for the volume. ONTAP snapshots take just an instant to create from source volumes of any size. They are also designed to be as space efficient as possible by only consuming space for changed data. Snapshots can also be used to restore data in a variety of ways, including a complete and instant restore of the whole source volume, an instant restore of an individual file, or a manual, selective restore directly from the snapshot as if it were a read-only copy of the data at the point-in-time it was created.
Cloud Volumes ONTAP can also use snapshots to create clones of existing Docker volumes using NetApp FlexClone® technology. With FlexClone, you can create writable, space-efficient clones in an instant from source data of any size. Each clone shares common data blocks with its parent volume, and redirects data changes to new storage blocks. When the clone is no longer required, it can simply be deleted, which frees up any storage space is was consuming. Trident provides access to cloning capabilities through normal Docker volume commands as well, which provides easy access to data cloning for software professionals that need to setup test environments.
Cloud Volumes ONTAP also comes with many built-in features for making cloud storage more cost effective, such as thin provisioning, data deduplication, data compression, data compaction, and the automatic tiering of cold data to low cost object storage, such as Amazon S3 or Azure Blob. These features can be used in combination with each other and are applied to storage volumes transparently, which means that applications and services require no changes in order to benefit from them.
In this section, we will give you a Docker volume tutorial. We’ll take a look at some basic examples of using Trident for Docker to provision storage using Cloud Volumes ONTAP. Before using Trident, it is important to ensure that the host machine has the necessary operating systems packages installed to support access to the storage, whether that will be over NFS or iSCSI.
Trident uses a configuration file to find connection details for the Cloud Volumes ONTAP deployment it will access and for storing the default options to be used when creating new volumes, such as the Docker volume driver, aggregate, etc . The following shows an example configuration for using NFS storage:
{
"version": 1,
"storageDriverName": "ontap-nas",
"managementLIF": "10.0.0.1",
"dataLIF": "10.0.0.2",
"svm": "svm_nfs",
"username": "vsadmin",
"password": "secret",
"aggregate": "aggr1"
}
To use this configuration to install Trident, use a command such as the following: $ docker plugin install --grant-all-permissions --alias nas netapp/trident-plugin:18.07 config=nas-config.json
Multiple instances of Trident can be active at the same time, each with a different configuration. This allows you to create individual storage pools with varying I/O performance profiles or that use different access protocols. An alias, as shown in the command above, is used to reference a particular instance of Trident in Docker volume commands.
To create a new volume, simply execute a normal Docker volume command, specifying the name of the Trident instance to use. This will create an independent storage volume that can later be associated with a container.
$ docker volume create --driver nas --name nfs-storage
A Docker volume can be cloned by either creating a new snapshot or by using an existing one. The snapshot will define the initial dataset the clone contains. To use a new snapshot, use a command such as the following:
$ docker volume create --driver nas --name nfs-storage-clone -o from=nfs-storage
To search for existing snapshots and then use one of them to create a clone, use the commands shown below:
$ docker volume inspect nfs-storage # enumerates available snapshots
$ docker volume create --driver nas --name nfs-storage-clone -o from=nfs-storage -o fromSnapshot=nfs-storage-snapshot
Volumes can be destroyed when they are no longer required, which frees up any storage space they were using. The same command can also be used to remove volume clones.
$ docker volume rm nfs-storage
In this Docker volume tutorial, we’ve seen how Trident and Cloud Volumes ONTAP can be used to create a robust and scalable solution for deploying container storage with Docker. Gaining the advantages of NetApp storage services through native Docker commands opens up a new world of possibilities for provisioning container storage for DevOps workflows and more. Customers moving their containers to Kubernetes can continue to benefit from Cloud Volumes ONTAP through the use of Trident for Kubernetes.