Persistent volumes for Docker containers

Solid Bodies

Integration with Ceph

OpenStack and VMware are virtualization solutions that also manage the available physical storage in the background. If such a management layer does not exist in a setup, an existing Ceph cluster can also be integrated directly into Docker's volume system. However, this doesn't work as smoothly as would be desired from an administrator's point of view, because an official volume plugin from the manufacturer hasn't seen any updates for ages and simply doesn't work with current Docker versions. Although you can find free alternatives, one of them is marked as "experimental" and another is also orphaned. At the time of going to press, the best chances were offered with the rbd plugin by developer Wetopi: It works with current Docker versions and can also communicate with current Ceph versions.

Please note that the plugin requires access to the Consul service discovery and configuration tool, because it stores any configuration data beyond the boundaries of the hosts. The parameters that can be stored in Consul are listed by the plugin author on the plugin page on Docker Hub [3]. If the required parameters are unclear, the Docker administrator should consult an administrator of the running Ceph cluster.

As soon as Consul is running with the corresponding configuration (Figure 3), a Ceph cluster is available in the setup; assuming that at least Docker 1.13.1 is used, the plugin can be installed with the command:

Figure 3: Ceph volumes in Docker can be used with the Wetopi plugin.
$ docker plugin install wetopi/rbd --alias=wetopi/rbd LOG_LEVEL=1 RBD_CONF_KEYRING_USER=client.admin RBD_CONF_KEYRING_KEY="KEY"

The values for RBD_CONF_KEYRING_USER and RBD_CONF_KEYRING_KEY are also available from the Ceph admin. Entering Docker plugin ls then shows whether the installation worked (Figure 4).

Figure 4: The docker plugin ls command shows the currently loaded plugins. You can use several plugins at the same time.

The following command finally creates a volume called it-admin-test, which can then be connected to a container:

$ docker volume create -d wetopi/rbd -o pool=rbd -o size=206 it-admin-test

The size value describes the volume size in megabytes; the pool value refers to the Ceph pool in which the new volume is created. If the Ceph admin provides another pool for Docker volumes, the value must be adjusted accordingly.

Docker Volumes in Everyday Life

The three paths described here based on OpenStack, VMware, and Ceph each end with the docker command to create a volume. However, this is not the only task you have to complete when handling volumes. The most attractive volume is worth nothing if it is not connected to a container, as is the case for a container with Nginx:

$ docker run -d -it --volume-driver wetopi/rbd --name=nginx --mount source=it-admin-test, destination=/usr/share/nginx/html, readonly nginx:latest

The command mounts the it-admin-test volume in the /usr/share/ path within the container. Note that Docker automatically copies content that is already there to the volume. The readonly parameter at the end ensures you can read, but not modify, the directory in the container.

If you want to get rid of the volume at a later time, stop and then delete the container and the volume with the command:

docker volume rm <name>

The example above also contains the volume driver to be used. If you use Fuxi with OpenStack or VMware instead, the corresponding name must be entered after --volume-driver. Some volume drivers also offer the option of passing parameters when mounting the volume: In the example, these should be separated by commas after --mount.

If you want to find out about existing volumes, the docker volume ls command displays the volumes currently created, and docker volume inspect <Name> outputs the details of a container.

Conclusions

Containerized applications cannot do without persistent data storage. To connect to a storage back end, Docker offers the concept of storage volumes, so OpenStack, vSphere, or Ceph storage can be used in the same way as storage appliances from various manufacturers.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=