Chakit Arora
Chakit's Blog

Chakit's Blog

What is docker and why everyone is using it?

What is docker and why everyone is using it?

Chakit Arora's photo
Chakit Arora
·Oct 23, 2021·

3 min read

What is docker and why everybody is using it? A thread.

"But it works on my machine!" We all heard this, and we all face this problem in our daily lives. There are times when a few or lot of people are working on an application, and it often happens that it works on a machine and not on the other one.

Setting up an application on a new machine is always a pain, there are so many things involved. Even during running the tests, it happens a lot. This is the easiest and most used way to explain what docker is and how it is beneficial.

I will try and explain it without using a lot of technical terms. Docker is an open-source containerization platform. Docker uses a thing called containers. This is completely different than a Virtual Machine. A Virtual Machine comes with its own Operating System.

And for each app, you need a new virtual machine. On the other hand, docker containers can use the same host's kernel.

A container is something that is just bundled up with all the requirements for your application and can be shipped anywhere. It's an isolated environment for your application. It is a form of virtualization but has a lot more benefits. You can literally run it on any machine!

The other important thing to understand is docker image. A way to understand it is like classes and objects, where a class is an image and an object is a container. The images are used to run containers. Docker hub contains a lot of common images, you can even build your own.

Let's take an example to see what and how it all works. Consider you decided to go with MongoDB for your existing application. Now you will need to download and install MongoDB. You can set it up with a database and a password including some collections.

Now the other thing you can do is pull up the image for MongoDB from docker hub, and run a container with that using the same configurations you can do for a normal one. Now, this way you have MongoDB running on your machine without even installing it.

This comes to a lot more significance when you need multiple things like MongoDB. Maybe you need redis, a python env, nginx, and a SQL DB too! What you can do is, take all the images and build containers.

Docker gives you a tool named docker-compose to build and start multiple containers at once. You can define all the config in one file mentioning what all you need and booom! Use that anywhere. Use that on any machine and you don't need to do messy installation every time.

Docker gives a lot more features like volumes, networks, etc. Volumes are so that you can have a specific place at your machine to store your data. In our case may be to store the data for mongoDB, so that whenever we stop, delete or make a new container we can use the same data.

Docker allows you to even make different networks. So that one container can communicate with the other one easily. You can have multiple networks for a particular application regarding the needs.

Docker is a great solution. It can be a little tricky at the start but is of a great use. A lot and lot of companies and projects nowadays use docker to make everything better and easy!. It's very exiciting. And as always - You cannot avoid it for long!

Thank you so much for reading, I hope you liked it.

If you have any questions or suggestions, please leave a comment below or feel free to reach out.

 
Share this