A Quick Introduction to Docker

Barış Tutakli
3 min readMay 22, 2022

In this post, I don’t like to bother you with a lot of technical words. So, I’m going to explain Docker as simple as I can.

Have you ever deployed a project into a remote server? Four years ago, I developed a blog and wanted to deploy it on a remote server. That was the beginning of the whole story because when I ran the project, the project didn’t work as I expected :(

The project didn’t work because of the dependencies and version related problems. What was the solution to avoid these problems? As usual, let’s start questioning together😊 and discover Docker.

What does virtualization mean?

Consider that you have only one computer hosting Windows operation system. Then you decided to learn Linux, will you buy another computer or switch from windows to Linux? If you don’t get used to Linux and wanted to switch from Linux to Windows later, Would you follow all the steps to switch from Linux to windows. You will spend a lot of money or a lot of time depending on your choice. Relax you are not alone😊

In the past, people came out with a solution to decrease the hardware costs and improve utilization of the physical computer hardware, etc. They aimed to separate the software layer and hardware layer of a computer. This process is called virtualization. Then, Virtual machines came to the scene. Virtual machines allow you to host multiple operation systems on your computer and are managed by a hypervisor. For instance, Ubuntu can be installed inside Windows. Isn’t it amazing? A computer within a computer(inception😊)

Although there are some disadvantages of virtual machines for instance each operating system takes up memory spaces and spinning up a virtual machine takes time. Have you ever tried to host 20 VMs on one machine? If the hardware broke down what will happen? All the VMs might shut down(of course there might be solutions to avoid the disaster).

What does Docker images mean?

A docker image is like a scaffold to create a container for an application.

What does containers mean?

As virtual machines allow you to host multiple operating systems, they take up memory spaces. Wouldn’t you better remove unnecessary applications and services from your virtual machine? In this way, your application might use more memory spaces than before and will be isolated. Isn’t it cool? So, I could have used Docker to package the blog application into containers😅.

Containers are an abstraction at the app layer that packages code and dependencies together.

Let’s do some exercises!!!

First of all, we need to pull ubuntu image and run the image.

You can check whether the image is downloaded by “Docker images” command. This will show you the list of downloaded images.

if the image exists locally, it will run the images. Otherwise it will download the image. if this is the first time you use ubuntu after installation, run the script below:

We need to install figlet to print inputs using large characters.

Let’s print hello world!!!

When you run the script above, you will see the following output:

Let’s assume that you exit and want to rerun the same container. You can use the following command:

Let’s do the same thins using Dockerfile. Create a dockerfile and write the following commands:

Now we need to build the container image and run these two commands in the same directory as the Dockerfile.

The output will be the same as below:

Would you like to help me to better my articles?🙂 Do let me know your view on this 🙂 See you next time!

--

--