DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Welcome to Docker! 🐳
Edel Prado
Edel Prado

Posted on

Welcome to Docker! 🐳

Hi! I’m Eddie Prado and I wanted to showcase the amazing Docker platform! In this blog, I want to explain to you what docker is, how it works, and reasons why you should learn the ins and outs of it.
_

What is Docker?

First things first, what is Docker exactly? To put it simply, it is a platform for building, running, and shipping applications. So, if the app you are developing works on your machine, it will run on someone else’s machine via containers.
_

Let’s look at an example where Docker would have been a great tool to have:

Developer A is part of a team that are creating an app that could revolutionize how we see data. Dev-A, after long sleepless nights, gets his code running! Woohoo! Now he needs to send it to Developer B for testing and review. Dev-B downloads Dev-A’s app onto to his machine, but it won’t run. After half a workday of trial and error, Dev-A and Dev-B have the app working by updating, downgrading, and replacing software and files. Phew! Now Dev-B can finally do his testing, but the app still must go through many other channels before it can publish. This scenario will keep repeating itself unless the team matches Dev-A’s machine configuration to their own machine which is just not possible when everyone is working on their own distinct projects that require different configurations. So, how could we solve this problem?

Well, there are two routes you could possibly go.
_
_

πŸ–₯ Virtual Machines Vs. Docker! 🐳

One way to resolve this issue would be to use a virtual machine. A virtual machine, or VM for short, isn’t any different than other physical computers. It uses its own CPU, memory, disk, and can even connect to the internet! While the hardware of a computer is physical and tangible, VMs are often thought of as software-defined computers within physical servers. While virtual machines may have some positives like trying new operating systems, running old software, or developing software for other systems, the negatives severely slow down the development process.

One bad side of VMs is the need to have a operating system for every virtual machine you use. On top of that, those operating systems need to be licensed, patched, and monitored. Another downside would be the slow start up. Just like physical computers, VMs need to boot up, and depending on the task at hand, you may need to boot up several different virtual machines. This leads me to my final point. Virtual machines are resource intensive. These resources being CPU, memory, and disk space allocation.
What could counter these negatives? Docker, that’s what!

Docker turns the negatives from VMs into positives, and by doing so, it streamlines the app development process! While virtual machines need their own operating systems, Docker does not. It uses the hosts own OS kernel, so there is no need to buy a separate license or worry about extra patches. Since this eliminates the need of a guest OS which is essential for virtual machines to function, Docker is incredibly lightweight. Because of this, Docker boot up times are minimal when compared to VMs, and Docker uses less resources by downloading only the most essential files/software to run an application.

Here is a comparison of the infrastructure between Docker and Virtual Machines

VM and Docker infrastructure
_
_

How does Docker work?

To answer that question, there are three things you must know.

  1. Dockerfile - which is plan for building a Docker image.
  2. Image - which is a template for running a container
  3. Container - which is a running process/application

The process starts with replicating an environment (like Dev-A’s machine configuration!). The person who is developing the application creates the environment using the dockerfile. After the dockerfile has been created, any developer will have the ability to create an image, which is an immutable snapshot of the environment, using the dockerfile. These images can be pushed up to the cloud (DockerHub) for others to pull down to their local machine. They then can create a container which is a running process of the image that was pulled from the cloud.
_

Let’s go back to our Dev-A and Dev-B example. This time we will use Docker!

Dev-A is in charge of creating an app that could revolutionize how we use data. Before they start their long journey of developing said application, they create a dockerfile with a base image in the root of the project. Dev-A will continue to update it with the necessary files used in the app throughout his process. An unspecified amount of time later, Dev-A finishes his app! They then build an image, which creates an image ID, using the terminal. Dev-A then pushes said image to DockerHub and gives the image key to Dev-B to pull the image down to his local machine. Dev-B does just that and begins running an isolated container which flawlessly runs the app. Developer B instantly gets to work testing and reviewing the code while Dev-A goes home and gets his much needed sleep.

When working in a team, Docker is essential in creating a efficient and streamlined development process. It not only increases productivity, but also allows for multiple containers to run on the same machine, maintain isolated applications, and allows for quick and easy configurations!
_
_

Where to download the Docker Desktop application?

To install Docker head to https://docs.docker.com/get-docker/ and download the Docker Desktop application for your operating system. Docker is available for Mac, Windows, and Linux. There is also a VS Code extension for docker. Check out Tutorial: Get started with Docker to get more details on that.

I heavily recommend checking out the below resources to get an even better grasp on how powerful Docker is. Especially when collaborating as a team.
_

Resources:

Video:
Great video explaining how Docker works.

_

Extra Reading:

Top comments (1)

Collapse
 
moscatena profile image
Moscatena

Thanks for this! I've been passively using Docker to run the Pi Blockchain in my computer, but never really understood why. Now I do!

πŸ‘‹ Hey, my name is Noah and I’m the one who set up this ad. My job is to get you to join DEV, so if you fancy doing me a favor, I’d love for you to create an account.

If you found DEV from searching around, here are a couple of our most popular articles on DEV: