Docker Basics

Today's article is a short introductory piece about Docker (what it means and what it's used for). Let's get right into it



First off, what is docker? Docker is a container tool that allows developers and organizations to build, run and deploy applications by using containers in an isolated environment. It takes away the repetitive task of a development life cycle thereby making the process fast, easy, and portable for deployment. As an example, consider a car wash that takes in a dirty car to clean, wash, and polish. After the operation is done, we get a shiny car. Docker is similar to this, it is like a box (car wash) that takes in an input, does all the required tasks, and then sends an output.

Docker is a containerization service that ships applications in a container but what is a "container"? A container basically allows developers to package up their application with its libraries and dependencies, and ship it as a single package. They are basically the bread and butter of Docker, they insure your app into an isolated system with its specific needs. Also, these containers are a running instance of a docker image.


What then is a "docker image"? A docker image is a file that is used to execute code in a docker container. Think of a class where containers are the objects of that class.  You first make a Dockerfile (set of instructions) then build an image from that Dockerfile, then start containers from the Docker image.


How then do you host your docker images? This is where "docker-registry" comes in. Docker Registry is basically an image registry where you upload your images and you can also download images created by others. It serves as a target for your docker push and docker pull commands. Docker hub is the default public registry for docker.


Virtual Machine vs Docker (Differences) 

When I first heard about docker, the first thing that came to my mind was a virtual machine. Some of the questions that I had were, are they the same? is docker here to take over the virtual machine? amongst others. After a couple of research, I realized that they are different. I will be sharing 5 differences between the two.
Image from Cloud Academy



Virtual MachineDocker
Each Virtual Machine has a separate Operating System which causes more resources to be usedEach container can share the operating system without the need for a hypervisor
In terms of efficiency, Virtual Machine takes up more space in your RAM, and CPU time may be slowerDocker containers share many of their resources with their host system hence they require fewer things to be installed in order to run
Creating a Virtual Machine takes relatively a longer timeContainers can be created in seconds
Virtual Machines cannot have multiple tenants (Applications)Docker containers can have multiple tenants
To deploy an application, the Virtual Machine needs to start the entire operating system (OS) and that can cause a full boot processContainers were designed to save time in the deployment process of an application


After doing my research and having a better understanding of VMs and Docker, I can say that Docker has not taken over the use of Virtual Machine rather they are both complementary tools that serve different purposes in terms of workload and usage. Virtual Machines are usually built for static applications (applications that don't change often) while the Docker platform is built to be more flexible and can be updated often and easily.


Before I wrap up this article, I wanted to touch point quickly on "docker-compose". As described above, docker containers are used for running applications in an isolated environment. However, it may not always be a single container. Usually, you may have many containers coming together to act as one cohesive service. How then do you combine them together? This is what Docker Compose does. With docker-compose, you are able to run multiple containers at once. You can define all your configurations in one YAML file and start all the containers with one command. This allows developers to manage their codebases better and also faster since you don't need to always start each container manually.


That will be all from me today. I have learned a lot by putting this article together and I hope you have learned something from my blog today too. Thank you for stopping by my little corner and I hope to see you soon...✌️

Food for Thought:- "Docker is not in conflict with VMs. We all know that there is no one solution for all problems".


HAPPY CODING!!! ❤️.