Docker – a Revolutionary Container Platform
Before going into the analysis, let’s have a brief idea about Containers and Docker. A Container is an executable package of software designed to provide an isolated environment for applications to run in a host server. They have all the necessary code, runtime, libraries etc. to provide a safe environment for the application software. Prominent enterprises like Uber, Facebook, Google etc are using Containers in a very high scale. Docker is a software container platform and is used to create container units on host machines. Many such units share the host’s OS, RAM, Processor and other resources. Disk usage is minimized by sharing filesystem layers and common files. Docker containers help in many aspects for Software Lifecycle, starting from development to deployment and implementation. It provides an agile continuous integration platform with isolated units for development teams, with development, test and production environments. It makes a server compatible for a wide variety of software applications that have different dependencies. Docker makes the host platform portable and distributed by virtue of its self sufficient and isolated container feature. All these come along with reduced need of computing power and space, since Docker Containers use the same Kernel in a host, rather than VMs using separate guest OS.
Docker Containers run on all major Linux flavors. A wide variety of technologies are using Docker, like: NGINX, Redis, ElasticSearch, MongoDB etc. Docker can run seven containers at a time, thus providing scalability and containers are faster than VMs. Docker provides enhanced security to apps deployed inside containers by isolating them from the underlying infrastructure.
What about Databases and Docker
Docker provides a portable and distributable safe haven for database instances, using the isolated container structure. It comes with handy support for deploying self sufficient isolated database environments. The Docker framework allows installation and management of MySQL, MariaDB etc. For this, MySQL and MariaDB Server Docker images are available at official repositories or registries of Docker. After downloading the database server images, Docker is used to create containers for these images. Docker CLI supports all types of control and configuration operations needed for these images to run as fully fledged database instances in isolated containers. Since Docker containers are lightweight abstractions of the host machine, Docker allocates dynamic IP addresses to its containers. Since peer connections are needed, like a peer container running a CMS software needs a static address to connect with the peer database container, Docker allows naming of the containers and instead of the changing IPs, these names, like mysql-container, wordpress-container can be used for interconnections. For incoming connections, the container’s port can be mapped into a host machine port.
The Docker containers provide abstracted filesystem images for the database instances to Read and Write. Also databases can access data directories mounted outside the container, provided they are visible inside the container.
Now, what about the downside?
One criticism is about Volume Management in Docker. If file locking is not properly done, chances are there for an instance to write on another’s file, causing data corruption. Only one running container is allowed to access the database data directory and if another database container tries to access an unlocked file in the former, it may cause startup errors for the latter database instance.
Since filesystems and tools of host can be made accessible to containers and vice versa, serious consequences may happen if a resource in an already configured resource path is removed or stopped. There are security concerns also in this kind of cross-access, especially when security configuration is not carefully done. Another one is Container Crash. Since containers are lightweight images and coupled for distributed workflows, a crash can trigger a cascade of crashes and the data might be corrupted in a database due to an abrupt termination of the database processes.
Next is Over Allocation of Resources issue. Since databases are important components of an enterprise system, and Containers are allocated resources in advance, database containers will get the privilege of the upper limit of resources – memory and computing, even though they are not being used unless during a peak load time. This causes wastage of resources. Also Docker network issues were reported, and when the deployment constitutes of a cluster of replicas that need to communicate 24/7 to main data integrity, a network trouble can cause the replicas to go out of sync.
Docker containers in general are made for stateless software applications and hence reset its data cache every few hours. A database that very much needs a stateful environment may not get it from a Docker Container, without proper configuration and allocation of resources. In case of an abrupt shutdown or crash, data corruption may happen due to this lack of persistence. More than it, the price for extra level of isolation Docker provides for creating a stateful environment to databases, is the extra resource allocation needed in terms of cache space and computing.
Another important argument against connecting Docker and databases are the lack of stability and frequent reporting of bugs with the Docker Container deployment. In a production environment, these can cause costly downtimes in terms of money and reputation. But as with any technology that spans from micro to huge enterprise level, these obviously happen, and a smart engineering team and prompt support team can overcome these hurdles using proper knowledge and expertise.
Docker containers are an effective way of streamlining application development, testing, deployment and distribution. It offers the much needed portability and flexibility in a cross platform, multi infrastructure host space across the world. While it is an intelligent choice for deploying stateless applications, with some extra planning and effort, they can be made suitable for deploying highly efficient and scalable database systems, irrespective of how and where they are hosted such as clusters, master-slave deployments, cloud instances etc. and this is where Docker gets its upper hand over criticism.