Data persistence and portability use cases such as moving database containers between hosts and reattaching existing data volumes from shared storage environments can be challenging. When a Docker container moves with a standard volume driver, its data volume stays in place and the container starts with an empty volume.
In order to make moving Docker containers and data volumes together easy, ClusterHQ developed Flocker. Flocker is an open-source container data volume manager for Dockerized applications that gives DevOps teams the ability to run containerized stateful services such as databases in production.
Calsoft Whitepaper: An Analysis of Three Transaction Processing Architectures
According to ClusterHQ, a Docker data volume that is tied to a single server, a Flocker data volume, called a dataset, is portable and can be used with any container in your cluster. Flocker manages Docker containers and data volumes together.
The Flocker Driver/plugin for Docker allows you to provision Flocker volumes directly from within Docker. This means you don’t have to use a separate tool to manage your persistent data volumes.
While creating a container with a data volume, we just specify the –volume-driver=flocker flag, and then specify a name and mountpoint, e.g. -v my-volume:/mount/point.
Flockerctl is the CLI tool for controlling the flocker services, it has commands like listing nodes, creating volumes and moving them around. Using the flockerctl we can also provision the volumes for docker.
We can check the version of flocker using following command
[root@flocker-Node1 ~]# flockerctl version prototype version 0.0.1
List the Nodes:
[root@flocker-Node1 ~]# flockerctl list-nodes SERVER ADDRESS bf5d33ee 192.168.5.35 08ad1785 192.168.5.36
[root@flocker-Node1 ~]# flockerctl create -n bf5d33ee -m name=Test -s 15G
created dataset in configuration, manually poll state with ‘flocker-volumes list’ to see it show up.
[root@flocker-Node1 ~]# flockerctl ls DATASET SIZE METADATA STATUS SERVER 8af507ae-5c24-4d55-9d39-c16ff7fce7b9 15.00G name=Test attached ✅ bf5d33ee (192.168.5.35)
Map Volume to the Docker container:
[root@flocker-Node1 ~]# docker run -it -v /flocker/8af507ae-5c24-4d55-9d39-c16ff7fce7b9:/Calsoft --name=Yogesh123 centos /bin/bash or [root@flocker-Node1 ~]# docker run -it -v sanity:/data --volume-driver flocker --name=Yogesh12345 centos /bin/bash
Move volume from one node to other node:
[root@flocker-Node1 ~]# flockerctl ls DATASET SIZE METADATA STATUS SERVER 0e4398e0-6926-40b2-91e9-bd5099e28494 75.00G name=sanity attached ✅ bf5d33ee (192.168.5.35) 8af507ae-5c24-4d55-9d39-c16ff7fce7b9 15.00G name=Test attached ✅ bf5d33ee (192.168.5.35) [root@flocker-Node1 ~]# flockerctl move -d 0e4398e0-6926-40b2-91e9-bd5099e28494 -t 08ad1785
initiated move of dataset, please check state to observe it actually move.
[root@flocker-Node2 ~]flockerctl ls DATASET SIZE METADATA STATUS SERVER 0e4398e0-6926-40b2-91e9-bd5099e28494 75.00G name=sanity attached ✅ 08ad1785 (192.168.5.36) 8af507ae-5c24-4d55-9d39-c16ff7fce7b9 15.00G name=Test attached ✅ bf5d33ee (192.168.5.35)
[root@flocker-Node2 ~]#flockerctl destroy -d 0e4398e0-6926-40b2-91e9-bd5099e28494
marked dataset as deleted. poll list manually to see it disappear.
Calsoft has deep expertise in containerization of Storage and Networking products. With our in-depth understanding of various containerization technologies like Docker, Kubernetes, Apache Mesos and Coreos, we have helped ISVs to design and develop solutions in and around these technologies.
His experience is across various technology domains; from Systems Engineering, Distributed Computing to Storage, Virtualization and Cloud computing.
Latest posts by Yogesh Patil (see all)
- Docker Swarm & Flocker Driver Integration - September 26, 2016
- Container Clustering & Management: Docker Swarm, Kubernetes & Apache Mesos and Marathon - September 7, 2016
- Flocker Driver/Plugin for Storage Arrays - July 19, 2016