DEV Community

Cover image for A beginner friendly approach to Docker
Shasheesh Purohit
Shasheesh Purohit

Posted on

A beginner friendly approach to Docker

Topics covered:

  • What is docker?
  • Why do we need docker?
  • What are docker images?
  • How does docker compare to Virtual Machines?

So let's begin with the easy question first:

What is docker?

  • Docker is a virtualization software which makes developing and deploying applications easier.

Well okay great it's a software that makes developing and deploying applications easier, yay that is great, but how?

That's the interesting part, Imagine a scenario where a team of developers consists of 10 people, now let's say you all are working on an app that consists of around 5 different services (eg: MongoDB, redis, etc). Now all of the 10 developers might need to install these services first in their machine to run the app and also keeping in mind the versions of the various services, too much right?

Well here's where docker comes into play. Docker basically helps you build an executable docker image which helps you to create running instances of the image which are called containers.

Okay great, but hey, what is a docker image?

  • A docker image is nothing but an executable application artifcat.

In simple terms it is a collection of:

  • Compiled application code
  • Any service that is needed (eg: node, npm)
  • Linux (used most probably as base image)

So basically a docker image includes the application source code along with it's complete environment configuration. You may also add environment variables, create directories, files, etc.

Now you know what a docker image is! but hey what is that container thing everyone keeps talking about?

Well containers are nothing but running instances of docker images, imagine docker image being a class and containers being the objects.

Since now you're familiar with docker images and containers, let's get back to our problem of all developers needing to install all the services. Well now all they need is the docker image of the services and each services can be run with simple docker commands, which will be same throughout all the OS along for various services.

Talking about this in a bigger picture, until now it was just the developers having to install various services, but in a large organization this is done by operations team which performs the following:

1) Developer combines and provides the compiled application to the operations team

2) Operations team installs the various services on the server required to run the application.

3) Application is deployed to the server

The issue with above approach is at times there can be issues running the compiled code on the OS of the server if that differs from the OS where it was compiled.

Hence with docker coming into the picture, the developer can now just provide the docker image of the application to the operations team and all the operations team needs to do is install docker on the server and voila! you're ready to sail the container.

Now let's also talk about how docker differs from virtual machines?

Well the main difference in docker and virtual machines is the part of the system that is being virtualized i.e in a virtual machine both the application layer and the OS kernel is virtualized whereas in docker it is only the application layer and docker images share the host machine's OS kernel, hence they are also quicker to initialize considering you don't need to boot up a kernel for each image.

Highly recommend watching this video to explore more about docker: Docker Crash Course

Top comments (0)