Docker Container: An Overview
If you are a Developer, chances are you not only know about containers but is also using one. Containers are now being used more than ever in application development as well as deployments & Docker is the leading provider for software container platform. Dockers are being adopted at fast pace by organizations & are replacing virtual machines when it comes to application development/deployment.
Docker containers are used for developing, shipping & running applications. Docker provides us ability to isolate an application into an environment called containers & containers have everything that is required to make an application work. Docker helps developers overcome challenges in dependency management, application scaling and partial updates of applications.
Docker offers a simple way to package an application and its run-time dependencies into a single container; it also provides a run-time abstraction that enables the container to run across different versions of the Linux kernel.
Since dockers use host’s kernel & does not require its own hypervisor to run, they are very lightweight in terms of resources i.e. they require less HDD size, less memory & CPU. When compared to virtual machines with both having same hardware, dockers can run more applications & that too at improved performance.
Components of Dockers
A Docker may be divided into four components & those are Client & Server, Docker Images, Docker Containers & Docker registries.
Server & Clients
Docker container uses Server-Client architecture. Docker client talks to Docker daemon either using REST API or over UNIX sockets or a network interface, then docker daemon either builds or runs the docker containers. Dockers client can run same system or Docker client can connect to a remote daemon. Docker client the primary interface to interact with daemon & it’s the only way to communicate with docker daemon. Commands that are issued to clients are then sent to daemon for execution.
Docker Images are read-only templates or blueprints with instructions for creating a Docker container. It is a collection of file system changes i.e application code, system libraries etc and commands for use within a container runtime. Images used for creating a docker container can be created from scratch or we can also use other images & modify them as per our needs before using. For example you can create a Docker image that uses CentOS as server with Jboss & Apache installed & all other configurations to make an application work.
Definition for a container is written in a text file known as Dockerfile. Dockerfile contains simple syntax for the steps needed to create an image & run it. Each instruction in dockerfile creates a layer in the image & we can only edit some layers in docker file to create another custom image.
Container is a running instance of the image that is created after launching a Docker Image. Container is an isolated space that is used for launching an application, all containers are isolated from each other but access to resources between containers can be granted.
We can create, run, stop, delete or move a container using API or via CLI. We can also connect storage, connect a container to one or more network & can also create an image based on the current state.
A Docker registry stores docker images. Public registries are provided via Docker Hub & Docker Cloud & can be used by anyone. Also by default, Dockers looks for images on Docker Hub but we can use our own private registry.
Code pipeline management
When a code reaches from development to testing to production, chances are that due some changes in different environment you might face problems. But with dockers, you have consistent environment for your application which make a developer’s life & production cycle much easier.
Main advantage of Docker is that it allows consolidating multiple servers& thus allows you to save cost on costly hardware. Though VMs accomplish the same but with Dockers, server consolidation is far more effective & management an easy task.
Whether its due to compliance or due to security, app isolation can be easily achieved with Dockers containers on servers hosting multiple applications.
Dockers are highly portable i.e. they can run on a laptop & same container can then be used in staging or production environment as well. With Docker’s portability & lightweight nature, it makes it easy for organizations to scale up or tear down applications as & when needed in almost real time.
Docker is serious game changer & has brought about a positive change in the IT field, especially Application Development. With cloud & dockers, one can have a working global application running in matter in minutes & hours which otherwise would have taken months to accomplish.