What is Docker?

What is Docker?

Being a developer, we all must have faced the problem of "It works on my machine". So, what could be some of the possible reasons for this problem?

  • Firstly, some files or dependencies might be missing which is required for your application to run
  • Second, your system might have a different version of software installed
  • Third, your system configuration might be different

To solve this problem here comes Docker to the rescue. The official documentation of Docker defines

Docker is an open platform for developing, shipping, and running your applications

Okay, you might still didn't get what it does. So, let's understand the things here. Let's say your team has been given a task to develop an end-to-end application that includes your frontend, database, etc. Untitled-1.png They were facing difficulty developing the application because of the following reasons:

  • The compatibility of the components with the underlying Operating System (OS) was an issue. They had to make ensure that all these components are compatible with the version of the OS they were using.
  • When a new developer joins the team, the developer has to go through all the steps to configure the environment to run the application. This takes a lot of time and effort. Untitled-3.png The above diagram shows that you have to go through various steps of configuration for different components like Frontend, User DB, etc, and in different environments like Developer Laptop, Production, QA, etc. This matrix is called Matrix from Hell.

Untitled-2.png Untitled-4.png Docker solves this problem by decoupling the components or applications from the underlying OS and hardware infrastructure. Docker provides the ability to package the application with all the necessary dependencies and configuration. This package is called a Container. In the above diagram, you can see that the different components are packed inside a container and run on top of Docker which decouples it from the underlying OS and hardware. And in the matrix, the blue container is the Docker container. This container is portable and can be shared and run on any cloud or machine without the problem of "It works on my machine" because the docker container itself is an isolated environment that contains everything that your application needs for it to be up and running.

Here we have come across the term container. So, what is Container?

As mentioned above, Container is a completely isolated environment that has all the required dependencies, libraries, and configuration needed for your application to run, and not only that it also has its own processes, network interfaces, etc.

Now, you might come across another term called Image in Docker. So, what is an Image?

The image is a template for the container. It contains all the instructions for a container to be created. These instructions are written in a file called Dockerfile. Since the image is just a template for the container, you can create multiple containers and run all those containers in a single machine. If you are familiar with the Object-Oriented paradigm, Image is like a class and Container is like an object. So, where can we find these images? Docker's default image registry is called Docker Hub. You can find other public images here and you can put up yours to share around.

Wrapping up by saying that learning Docker will help you a lot in your software development as a developer. It will make your life easier as a developer and will save a lot of time for you. Nowadays, almost every organization is adopting Docker, so now is a great time to start learning it.