Docker for Dummies, Literally

Saad A Akash
4 min readDec 26, 2018

--

No More Excuses, Robin!

Yes, those days are long gone when you could come up with those excuses. Whether or not you work in the software development industry, you should have, by now, heard of Docker even if you have the slightest connection with the development trend. If not, check out why it’s so darn popular! And if you’re still asking yourself why you, being a software engineer/developer, need to spare a substantially less time to learn a DevOps tool, being a stubborn developer is not a good thing. It never was.

Well, in short, Docker is a software container platform. You can create containerized applications, automate the deployment and have fun! Packing, shipping, and running — made simpler, easier & definitely, faster! With Docker, applications can comfortably run no matter where they are. Using Docker enables you to package your entire application with all of its dependencies with zero headache for compatibility issues or machine dependency.

To understand Docker, let’s have a quick look at some basic jargons in a minute or less.

Virtual Machines (VM)

What if I told you Your VM is running inside a VM?

In the simplest of its contexts, VM is nothing but an emulation of a real computer that can execute programs of sorts. And Hypervisor is basically what Virtual Machines run on top of.

A virtual machine is a program on a computer that works like it is a separate computer inside the main computer. The program that controls virtual machines is called a hypervisor and the computer that is running the virtual machine is called the host.

Docker Containers

The concept of Docker containers, similar to that of VM, also aims to achieve isolation in terms of applications and programs. Containers, as the term suggests, “contains” every little thing that an application may need to be executed. Think of it as a transportable box, filled with tools and libraries and settings and all that’s required for the execution. So you may ask how the concept of Docker is any different than that of VM and in that case, take a look at this one:

Source: Toptal

Evidently enough, containers don’t require a full instance of OS, allowing multiple containers to run smoothly on a single host machine. Since containers share the host system’s kernel with other containers, unlike VM, it actually offers OS-level virtualization. Means, the processes inside the containers are as “native” as the actual native processes running on the host.

How to generate one?

Now that we know what a docker container really is, let’s talk about the process for docker container generation.

In one line, dockerfile builds a docker image, from which you can run docker container.

A dockerfile is a simple text file, with lines of instructions on how to build a docker image. So it’s basically a blueprint for images, that’s all. And images are blueprints for containers, similar to Class in Object Oriented Programming.

Not Interested in Generating One By Yourself?

Well, then there’s Docker Hub for you, the Github for docker images! Use this online cloud repository to search a pre-built image, pull it down & use it right away!

Let’s Write a Simple docker file

First, install docker by following the simple instructions from here. Then, let’s have a super quick look at some of the most frequently used docker file commands and what they actually mean, pay close attention to the comments with each command in the following:

A Node Dockerfile

This is a sample dockerfile with some of the basic commands for a Node app, which we’ll use, build and run to dockerize a NodeJS app in later parts of this series. Check out all the available commands here and follow this link to learn best practices for writing these dockerfiles.

What’s Next?

Go through the official docs and get started with developing your applications on Docker. But after spending a significant amount of time with docker containers, you’re more likely to see yourself & your team to face scalability & performance issues where you may have to create a dozen of new microservices to support another dozen of the new requirements from clients. For that, you may need to deploy those containers across a cluster of physical/virtual machines, which will eventually lead you to “container orchestration” to automate deployment, scaling and monitoring the availability of container-based applications!

There are a number of orchestration systems for Docker containers and Kubernetes is, undeniably, one of the best in the game. Docker also has its own native container management tool, Docker Swarm.

Kubernetes or Docker Swarm?

Do watch this simple explanation video to have a clear understanding of why and when to use Kubernetes to utilize its power which allows you to take advantage of your existing docker workloads & run them at scale. If you’re already working with Docker, Kubernetes is a logical next step for managing your workloads.

We’ll cover up Docker Architectures, Docker Compose, Docker Engine Commands and other deep dives in the next part and then dockerize a NodeJS application in the last part of this series. Stay tuned!

Happy Dockerizing! ❤

--

--

Saad A Akash

Writes simple, stupid & hence, readable “okay” codes with fewer WTFs/min from code reviews. github.com/SaadAAkash linkedin.com/in/saadaakash/ https://saad.ninja