Docker: What is Docker and Its Overview?

 

What is Docker?

Docker is a platform to build, ship and run applications by wrapping them in containers.

In docker, the applications are composed as images and  run them in containers. So docker is all about creating images and run them inside containers.

By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

The official documentation of the docker can be found at  https://docs.docker.com

The architecture of the docker can be found at https://docs.docker.com/engine/docker-overview/

 

What is Image and Container ?

A image is an lightweight, standalone and executable package of the software application. The image contains everything (including compiled source code,runtime dependencies, executable jars and libraries etc) that it needs to run the application.

container is a runtime instance of an image — what the image becomes in memory when actually executed. It runs completely isolated from the host environment by default, only accessing host files and ports if configured to do so.

The relationship between image and container can be described as follows. The image will be composed from the application source code  and it is the runtime executable version of the application. The container is the runtime representation of the image and the whole image will be run/executed in the container.

For instance, assumed that a php application that requires php and mysql in the runtime environment. Therefore the image should be packaged by providing those two dependencies. when the application is run in the container, those two dependencies will also run inside the container.

Multiple containers can be executed on the docker platform and they all will run as independent containers.

Package software.png

As you can see that  the docker platform can have multiple containers running on it. each container runs their own set of libraries and servers that are required to run the underlying docker image.

 

Are Docker Containers similar to Virtual Machines (VM) ?

No… They looks like same. But the are completely different. Lets look at why they are different and what are their differences.

 

Virtual Machine (VM)

As the name implies Virtual Machine is a machine that virtually running on a physical machine. Each VM has their own operating system(full version of the OS) , runtime libraries and installed apps. Therefore the size of a VM may take GB of space from the physical machine (It consumes high resources of the physical machine). There can be multiple VMs in a physical machine.  The following diagram illustrates the set of virtual machines created in a single physical machine.

Virtual_machine.png

Infrastructure represents the resources and software related to the physical machine. This includes the host’s machine operating system, runtime libraries and other resources.

Hypervisor is a piece of software that allows to run VM on host machine.  A computer on which a hypervisor runs one or more virtual machines is called a host machine, and each virtual machine is called a guest machineHypervisor is responsible for creating and maintaining VMs.  The virtual machines can access the host’s machine infrastructure and resources through the hypervisor.

 

Docker Containers

Docker containers run on top of the docker platform. They contains only the executable package of the application, libraries and dependent software/servers that are required to run the application. They do not have separate OS installations running on their own and they utilize the host machine’s OS. Therefore the size of the container may take MB of spaces (this may varies based on the size of the dependent softwares and libraries in the container) and thus containers are considered as light weight with compared to VM. The below diagram will demonstrate multiple dockers containers running on the docker platform installed in a single machine.

containers.png

 

Why Docker containers are good over VM?

Virtual Machine Docker Container
 more heavy in size.  (contains the fully copy of OS) light weight. (only the required softwares and dependencies are contained)
since it is more heavy, takes some times to boot up. (Slow to boot up) since it is light weight, speedy boot up with compared to VM
since the resource consumptions is high, the running of multiple VMs simultaneously may slow down the host machine performace. since the resource consumptions is lower, the running of multiple containers simultaneously may not drastically slow down the host machine performance.
having own OS and utilizes memory and resources allocated for the VM. It is limited to use only the resources allocated for VM. This cannot directly use/utilize the host’s machine resources and infrastructure. utilizes the OS and underlying resources(memory and others) of the host’s machine. If no other docker containers are not running at the moment, the running container can fully utilize the available resources of the host machine.

 

Now i believe that you have a clear understanding about how docker container differs from a virtual machine.

 

Installing Docker

You can follow the instructions given at official documentation for installing the docker.

https://docs.docker.com/engine/installation/

Once you have completed the installation process, you can verify the installation by checking the docker version.

 

Checking the docker version

There are two commands available to check the version of the docker. you can run one of the commands in the terminal. Then it will print the installed version.

docker -v
    OR
docker --version

 

Docker Hub

This is one of the most important place that you should be aware of.  This is a sort of repository that contains the published docker images. You can create your own docker image of your application and publish it here for later use or someone else to use. In addition, you can find any official docker image through this repository hub.

https://hub.docker.com/

Lets search for the “hello-world” docker image. You can see the list of found container images.  Is is always advised to go with official image if available.

Screen Shot 2018-01-06 at 11.14.38 PM.png

 

Lets run our first docker image

We will run the “hello-world” docker container to check whether the installation is working perfectly.  I will take you through a list of useful docker commands in a separate article (click here to see the list of important and frequently used Docker commands).  At the moment, just remember the syntax of following command for running the docker image.

docker  run  <image-name> 

 

So we can directly run the following command in the terminal to run the hello-world official image.

docker run hello-world

 

Screen Shot 2018-01-06 at 11.36.08 PM.png

 

If you observe the execution log properly, you can see that it works perfectly and prints “Hello from Docker!” . The important thing to note from the execution log is below two lines.

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

 

When you try to run a docker image, the docker platform first check whether the requested image is already available in the local registry. If it is locally available, then it will run the local image. Otherwise it will retrieve the image from the remote repository (from the Docker Hub) and run. If you want to look at and verify this behavior, run the image one more time and check the execution log.

 

Screen Shot 2018-01-06 at 11.52.01 PM.png

 

You can notice that this time it is not going to pull the image from remote repository. It will reuse and run the local image available.

The nice article of the docker architecture can be found at official documentation. It is worth to read it.  you can find it through https://docs.docker.com/engine/docker-overview/

In up coming articles, we will try to explore the cool features of Docker. Keep in touch!

 

2 thoughts on “Docker: What is Docker and Its Overview?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s