What is Docker?

Zwavhudi Mulelu
4 min readFeb 14, 2021

--

Image obtained from https://imgflip.com/i/1qjgml

“It works on my machine”

— A software developer proverb

What is docker?

In software development we create applications that require a specific set of dependencies, pre-installed applications, libraries, databases, and each might have a specific version. If any of these requirements are not met, an application either wont run or it may work differently on different machines.

This is where Docker comes in. Docker is a form of virtualisation and is thus similar to a Virtual Machine (VM), however, unlike a VM it does not contain an entire operating system. Docker shares resources such as the Operating System, memory, processing power and hard drive space directly with the host and this allows you to run multiple docker containers in a single host. Similar to running numerous mini-computers in one big computer. With Docker sharing resources with the host machine, this makes it more light-weight and therefore resulting in higher performance.

Docker is an open-source tool that is helpful in the development, deployment and running of applications through the use of virtual containerised environments called containers.

The amazing thing about Docker is that it allows you to successfully run the same application in any environment. Therefore you wouldn't have to worry about the platform or environment you are using because it works everywhere.

This is possible because in Docker, an application as well as all its dependencies such as source code, libraries and any other dependencies are packaged in the form of a Docker image. This Docker image can be deployed to the Docker environment where it can then be executed into a Docker container. Now, you might be wondering what a Docker image and Docker Container is.

Docker containers and Images

The concept of Docker images and containers can be hard to grasp at first, but it gets better with time. I’ll make use of a real world example to simplify the concept.

Docker image

A Docker image lightweight, standalone, executable package of software that is built from running a Dockerfile that contains instructions used to execute an application with specific dependencies. It can be reused and also deployed to any host.

A Dockerfile is a text file containing a bunch of instructions informing Docker on how the Docker image should be built.

Lets take a real world example of the money-making process i.e. printing bank notes. When bank notes get printed, something called a printing plate is used to model how these notes should look like. This model was probably designed and made many years ago, but the same model is still being reused as a reference to print bank notes even today. Think of an image as a bank note printing plate.

Image obtained from https://www.youtube.com/watch?v=92jZZbOUKmA

Now back to Docker. Docker images are layered, meaning you have a bunch of dependencies needed for a certain application in layers, for example if your application depends on Node, you would create a layer with Node. This can be your base image (yes, images can be built from other images). This is because the Node team has already created a Node image for you to use as a base image. If your application also requires Java , well you’d have a layer with that too and so on and so forth. Refer to this article to see how you can build an image for your app.

Docker container

If we go back to our real world example of printing bank notes, a Docker container would be analogous to a $100 bank note. And all these different $100 bank notes were created using a $100 printing plate which in our case can be the Docker image.

Image obtained from https://www.coindesk.com/money-printer-go-brrr-is-how-the-dollar-retains-reserve-status

Multiple Docker containers can be built using a single Docker image. It’s very important to note that a Docker container is an instance of a Docker image. This allows us to be consistent in our deployments i.e. deploy the same image in our dev, test and prod environment. In a case where your application requires different configuration properties for different environments these can be passed into your container through environment variables.

A Docker container is basically a storage for code and all its dependencies which enables applications to run fast and reliably in any computing environment.

Docker containers can be deployed to any computer or sever and can be run with absolutely no compatibility issues arising. Docker containers usually run a single distinct task such as a Node.js application or a MySQL database. In a situation where these two are dependent on each other, they can be networked together.

Image obtained from https://www.reddit.com/r/ProgrammerHumor/comments/cw58z7/it_works_on_my_machine/

Thanks for reading this far 🎉🎉🎉, this was a pretty long one 😅. Hope this helps you understand Docker better.

--

--

Zwavhudi Mulelu
Zwavhudi Mulelu

Written by Zwavhudi Mulelu

Software Enginner | I like sharing new tech info that I've learnt | Love music | Rick and Morty fan

No responses yet