DEV Community

Cover image for Docker - Basic Introduction.
Pratik Mishra
Pratik Mishra

Posted on

Docker - Basic Introduction.

Docker we have been hearing this buzzword for quiet a while now. Everyone is talking about docker so today let's unfold what docker is and get familiar with the basics of docker and I can guarantee that after getting to know about docker you'll never look behind.

So, What is Docker ??
The answer is pretty simple docker is a containerization service that helps you build, pack and ship your applications in a Container.

Containers ?? what is this, are we shipping containers in computers ??
As we know when we develop applicatons this application has certain dependencies inorder to function. Now when we send this application to our co-worker or friend who is working on the same project too, chances are that when your friend or co-worker runs this software it might not run and give some random errors or maybe they'll need to download and setup all of the dependencies before running the application. Now, why does this happen ?? maybe the version that you used to develop the application will not match on your friend's machine or he/she may not have all the dependencies installed in their machine for running your program or maybe the versions don't match, there can be a number of reasons why our program may not run on their machine and they'll need to spend hours to solve all the problems or to setup the development environment. This is where docker containers come into picture you can think of containers as a complete package for your application which bundles all of the dependencies/requirements into a single box known as a container. If that container runs on your machine it will definately run on every machine that has docker in it and your problem of "It runs on my machine" is solved permanently.

Now, let's look at the Docker Architecture and also let's differentiate docker from virtual machines as both go hand in hand and many people cannot differentiate both of them.
Alt Text
So, as we can see from the above figure docker engine sits on the host operating system and docker containers are deployed on top of the engine. This implies that docker uses the underlying host's Kernel ( using Namespaces and Control Groups - These are advanced topics and I don't want you'll to get overwhelmed with all these topics all at once I will make a seperate blog for these topics) to maintain the containers lifecycle and this is the reason why docker containers load up much quicker as compared to a VM.
In case of a VM we have something known as a Hypervisor which virtualises hardware resources for each virtual machine. Each Machine has it's own full fledged Operating System and their own Kernel. When you boot up a Virtual Machine it's boots up a heavy OS all from scratch and that is the reason it takes time inorder to boot.
In case of Docker if you see it uses the hosts kernel so when you spin up a container it doesn't needs to boot an entire os from scratch as it uses the hosts Operating Systems Resources. You can think of it in this way Instead of Virtualising Hardware Resources Docker Virtualises Hosts Operating System's Resources.

Using Docker You can literally start a Container within seconds. Also these Containers are basically a running instance of a Docker Image.

Now, What is this Docker Image ??
Images are basically a prototype for our containers you can think of images as a class and containers as object of that class. So in short Containers are an instance of an image. We first create a docker image from a Dockerfile ( Dockerfile is nothing but instructions to compile a docker image ) and if that build is successful we can spin up n number of containers from that image.
Alt Text

As you can see we first make a Dockerfile( instructions ) then build an image from that Dockerfile and finally start containers from that Docker Image.

Till now we saw that what is docker, containers, Dockerfile and Docker Images and basically how is Docker Different from a Virtual Machine.
This was just a Basic Overview of all the stuff in the upcoming blogs we'll deep dive into each of these components and have a look into the docker Engine like how everything is Being done under the hood and get a firm grip on docker so stay tuned for that.

I hope you got an overview of Docker and ready to dive in deep into Docker :)

Next Step,
Docker Engine - Deep Dive into Docker

Top comments (9)

Collapse
 
ashisha13 profile image
Ashish Agarkar

Simple and clear

Collapse
 
pratik6217 profile image
Pratik Mishra

Thankyou :)

Collapse
 
seveneye profile image
seveneye

When to use docker?

Collapse
 
pratik6217 profile image
Pratik Mishra

You can use it for literally anything and everything from containerizing your own applications for further use or to share your part of work with your colleagues or to scale your projects at a higher level (dev ops) docker has a lot of use cases.

Collapse
 
muzammilaalpha profile image
muzammilaalpha

Nice one!!

Collapse
 
pratik6217 profile image
Pratik Mishra

Thankyou :)

Collapse
 
theinsightfulcoder profile image
Sai Ashish

Well written!

Collapse
 
pratik6217 profile image
Pratik Mishra

Thankyou :)

Collapse
 
pratik6217 profile image
Pratik Mishra

Glad that you liked it :)