Introduction to Docker

Introduction to Docker

Have you ever struggled to get your application running on different computers or servers because of compatibility issues? Docker is like a magic box that can help you package your application with all its necessary parts, so it can work consistently on any computer or server, regardless of the environment. It's like a shipping container that contains everything your application needs to run, such as code, libraries, and system tools. With Docker, you can easily package and deploy your application without worrying about compatibility issues, and it can save you a lot of time and effort. In this blog, we'll explain how Docker works and how it can help you streamline your development process. Whether you're new to programming or an experienced developer, I'll make sure to keep things easy to understand and help you get started with Docker.

Before Docker

We could only run one application on one server. Every time we want to run a new application, we had to buy a new server, which might not be making sense to you now, but it previously it was like that. And the server cost was also too high. More hardware we had to buy so, obviously it was not environmental friendly.

VMware solved this problem by introducing virtual machines(VMs).

Through virtual machines, we could run various applications on one server at the same time. But virtual machines require their OS, and every OS requires some amount of hard disk.

It was really better than one application on one server, but since we need to use a new OS or separate OS to use virtual machine. It was really better than one application on one server, but as VMs provided many advantages, but it also had several disadvantages.

Some of them are following :-

  • It was not superfast.

  • Need dedicated OS to run.

  • Dedicated storage was required.

  • Dedicated Software was required.

  • CPU allocation was needed.

So overall we can say that it was good, but we want better.

If you are from a development background, you might have encountered this above meme.

Docker

Docker is a powerful tool that has become increasingly popular in the software industry. It allows developers to create, deploy, and run applications in containers, which are isolated environments that include everything needed to run the application.

So what is docker from a practical standpoint?

it's just a way to package software so it can run on any hardware. Now in order to understand how that process works, there are three things that you absolutely must know.

Docker file

A docker file is a blueprint for building.

A Dockerfile is a simple text file with instructions to build an image. If we do not have the docker file, to build the image and run the container word by word we used the command line interface according to our requirements. But this docker file helps us to provide the instruction on what needs to be pulled, what arguments need to be run after building the image, and providing some configurations

Docker Image

A docker image is a template for running

A Docker image is a file used to execute code in a Docker container. Docker images act as a set of instructions to build a Docker container, like a template. Docker images also act as the starting point when using Docker. An image is comparable to a snapshot in virtual machine (VM) environments.

Container

A container is a running process.

Suppose we have to transport car, piano and other stuffs at one location, so we loaded all the items in one big box and transport it.

The same way we use container, to send all required software to run the application and of course application, in one big box, called Container.

It works on my machine but if someone else with a different machine tries to run it with a different version of application, it might break.

The whole point of docker is to solve problems like this by reproducing environments. The developer who creates the software, can define the environment with a docker file, then any developer at that point can use the docker file to rebuild the environment which is saved as an immutable snapshot known as an image.

Images can be uploaded to the cloud in both public and private registries then any developer or server that wants to run that software can pull the image down to create a container which is just a running process of that image.

In other words, one image file can be used to spawn the same process multiple times in multiple places. And it's at that point where tools like Kubernetes(K8s) and Swarm come into play to scale containers to an infinite workload.

By using Docker, developers can ensure that their applications work consistently across different environments, reduce compatibility issues, and improve deployment speed and efficiency. With its comprehensive ecosystem of tools, Docker has become a popular choice for modern software development and deployment. As the industry continues to evolve, Docker is likely to play an even more important role in enabling developers to create and deploy applications quickly and reliably.

In conclusion, Docker is a powerful platform that simplifies the process of building, packaging, and deploying applications as containers. So, if you are a developer looking to streamline your application development and deployment process, Docker is definitely worth considering.

Thank you folks for reading till the end, if you find this blog helpful please like this blog.

Checkout my Portfolio

Did you find this article valuable?

Support Anurag Kumar by becoming a sponsor. Any amount is appreciated!