What Are the Docker Containers ?

What Are the Docker Containers ?

Docker provides ability to isolate your application from the underlying Operating System and Infrastructure. The lightweight environment which Docker uses to isolate and run the application is called as container.

This article explains why containers are lightweight and what is docker registry and how can you start on Docker.

This article is for absolute beginners and if you already are aware of why Docker is used and what is docker hub, you may want to skip this.

The Ancient World

Before taking look at what is Docker, let’s have a look at how the application deployment used to happen in the old world. Let’s consider a hypothetical scenario that your organization wants to create a set of Social Networking applications and try to think what course of action would have been taken by most of us at that time.

The development team starts on the development. The IT team is trying to figure out the infrastructure that would be required for the application to perform all the operations within acceptable response times.

For this, they would need to know what is the acceptable response time. They also need to know how much of data would be generated by people so that they can know what should be storage capacity. They need to know how many parallel users are required to be supported, how much processing power would be required, which operating systems and server to use, etc.

In most of the cases, the answers of these questions were not known to IT Team beforehand. The IT Team also could not wait until the application development and load testing of application is done, because they wanted infrastructure to be ready by that time.

Also, the IT team also did not want to take risk of getting into “poor performance of application” state because they choose cheaper infrastructure. So guess, what did they do ? You guessed it right, they purchased th highest power infrastructure.

Now, if after load testing it comes out that we do not need this bigger processing power or bigger RAMs, then your hardware is not getting used optimally.

Then Comes Virtual Machines

Then virtualization came. Let’s see how the deployment decisions might have been taken then.

The Hypervisor and VMWare allowed IT Teams to use their hardware efficiently. The IT Team deployed multiple virtual machines on that big infrastructure. Every virtual machine could consume part of processing power, part of storage and part of memory from its host.

Now, you were required to buy new infrastructure only if you really needed it. If you bought very high configuration infrastructure, you could use virtual machines to make its optimal use.

But with virtual machines, there were few shortcomings.

  • Every virtual machine had operating system and that operating system used to consume considerable amount of processing power, memory and storage. So if you have considerably small application hosted on virtual machine, probably, the resources taken by VM would be very high as compared to the resources consumed by your application.
  • Also Virtual machine has operating system, so it needs regular maintenance activities like updating operating system, antivirus and its updates, patches, etc.

Welcome to the Docker

The Docker is a platform for developers and sysadmins to build, share and run the applications with containers.

A container is nothing but a running process. This process has some added features which enables it to isolate the application from the hosting operating system / infrastructure and from other containers too.

A container has its own file system. The file system is provided by Docker Image. A docker image contains code, binaries, runtime, dependencies, file system, etc.

A container also shares most of the features with the host operating system, making it lightweight.

The term Containerization is used to describe the use of containers to deploy the application. With containerization, you can run your application on any operating system, any server or in cloud as well.

The Docker For Linux can run only Linux Applications while Docker For Windows can run only windows applications.

What is Docker Registry

Docker Registry stores the Docker Images. There is a public registry called as Docker Hub and everyone can use it. If you have Docker Data Center access, you can also use Docker Trusted Registry.

Let’s Play !

Docker natively runs on Linux. For MacOS and Windows, you can install Docker Desktop from this link.

Once installation is done, the machine restarts. Once the machine starts again, you can open command prompt and run docker -v command to know the docker version.

Next, you can try go to docker hub and see all the available images there. You can run below command to run the aspnetcore web application in docker container. This is from .Net Core samples from docker hub

docker run -it --rm -p 8000:80 --name aspnetcore_sample mcr.microsoft.com/dotnet/core/samples:aspnetapp

This command downloads the .Net Core Samples image and hosts it on port 8000. So if you try to browse http://localhost:8000 you can see the asp.net core sample application

Hope this article has provided you basic understanding of what is docker and how can you run the image in docker.

Leave a Reply