Docker World (Part 1)

Farid Tri Wicaksono
Life at Telkomsel
Published in
8 min readMay 15, 2024

Hello, I’m Farid, a backend developer. I’d like to shed some light on Docker, a revolutionary technology that has transformed the landscape of software development.

Let’s start by unraveling the mystery behind Docker. What exactly is Docker, and why has it become such a buzzword in the tech industry? These are questions we’ll tackle after exploring some essential concepts.

Docker, much like many cutting-edge technologies, emerged as a solution to a fundamental problem. This problem is vividly depicted in the image below.

This is flow software installation in traditional way

Looking at Image 1, it’s clear that installing and running a program or software isn’t easy. And this is where Docker comes in. Docker simplifies the process of installing and running programs or software without worrying about the setup and software dependencies.

Let’s take a simple example to see how easy Docker can be. For instance, let’s try installing and running Redis using Docker and without Docker. Redis itself is an in-memory data structure commonly used as a database, cache, or message broker.

If we got error when try install redis at part command “make” ,I could definitely go and troubleshoot this install that program and then try installing redis again, and I kind of get into endless cycle of trying to do all bellow troubleshooting as you I am installing and running software.

But let try how easy it is to run read as if you are making use of Docker instead. just run the command docker run -it redis, this command will install docker without any error.

Run redis using redis

From this example, we can see several reasons why Docker is highly beneficial and a fundamental skill to master today. Some of these reasons include:

  • Lower complexity
  • Easier to use
  • More flexible
  • Fixing software dependency issues
  • etc

Why use docker?

Docker makes it really easy to install and running software without worrying about setup or dependencies. Docker is really made it easy and really straight forward for you to install and run software on any given computer not just your computer but on web servers as well or any cloud based computing platform.

What docker is: To understand what is docker you have to know about docker Ecosystem.

Docker itself is actually a platform or ecosystem that includes various tools and projects involved in creating and running containers. But what exactly is meant by containers?

We’ll answer this question through some explanations below.

Docker client, server, Machine, Images, Hub, Composes are all projects tools pieces of software that come together to form a platform where ecosystem around creating and running something called containers, now if you run the command docker run redis something called docker CLI reached out to something called the Docker Hub and it downloaded a single file called an image.

An image is a single file containing all the dependencies and all the configuration required to run a very specific program, for example redis this which is what the image that you just downloaded was supposed to run.

This is a single file that gets stored on your hard drive and at some point time you can use this image to create something called a container.

A container is an instance of an image and you can kind of think it as being like a running program with it’s own isolated set of hardware resources so it kind of has its own little set or its own little space of memory has its own little space of networking technology and its own little space of hard drive space as well.

for example you try to run command: sudo docker run hello-world

When you execute the command “docker run,” Docker’s command-line interface (CLI) directs your system to Docker Hub, a repository of Docker images. From there, Docker downloads the specified Docker image file. This image file contains all the necessary dependencies and configurations required to run a particular program or software.

Once the Docker image is downloaded, Docker creates an instance of this image, which acts as an isolated environment for running the program or software. This instance inherits all the settings and configurations specified in the image file. It includes resources like memory allocation, disk space, and other system parameters necessary for the application to run smoothly.

In essence, Docker containers provide a lightweight and isolated environment for running applications, ensuring consistency and reproducibility across different computing environments. This approach streamlines the deployment process and facilitates efficient management of software dependencies.

The Docker Client or CLI can be considered as an interface or portal through which we interact with the Docker server or Daemon. The Docker Daemon is the actual software component of the Docker ecosystem responsible for various tasks such as creating container images, managing containers, uploading images, and other operations within the Docker environment.

okay, enough for explain about docker and how it work. Try to install and signup to docker hub

For Mac and Windows users, Docker Desktop provides a user-friendly solution. Meanwhile, users on other platforms can directly utilize Docker Engine. Here are some references for installation:

For Mac:
- Docker Desktop for Mac: [Docker CE Desktop for Mac](https://hub.docker.com/editions/community/docker-ce-desktop-mac)

For Windows:
- Docker Desktop for Windows: [Docker CE Desktop for Windows](https://hub.docker.com/editions/community/docker-ce-desktop-windows)

For CentOS:
- Docker Engine installation guide for CentOS: [Docker Engine for CentOS](https://docs.docker.com/engine/install/centos/)

For Ubuntu:
- Docker Engine installation guide for Ubuntu: [Docker Engine for Ubuntu](https://docs.docker.com/engine/install/ubuntu/)

For Red Hat Enterprise Linux (RHEL):
- Docker Engine installation guide for RHEL: [Docker Engine for RHEL](https://docs.docker.com/engine/install/rhel/)

These references provide step-by-step instructions for installing Docker on your respective operating systems.

after installation docker complete, open the terminal and run this command to validate your docker installation

docker version

Next, let’s begin our journey by executing the following command.

docker run hello-world

Above command will starts up the docker client or docker CLI, Docker CLI is in charge of taking commands from you kind of doing a little bit of processing on them and then communicating the commands over to something called the docker server, and docker server is in charge of the heavy lifting when we ran the command Docker run hello-world

That meant that we wanted to start up a new container using the image with the name of hello world, the hello world image has a tiny tittle program inside of it whose sole purpose or sole job is to print out the message that you see in the terminal.

Now when we ran that command and it was issued over to the docker server a series of actions very quickly occurred in background. The Docker server saw that we were trying to start up a new container using an image called hello world.

The first thing that the docker server did was check to see if it already had a local copy like a copy on your personal machine of the hello world image or that hello world file.So the docker server looked into something called the image cache.

Understanding images and containers is crucial in the Docker world, so we need to delve deeper into both terminologies. These terms are closely related to the operating system (OS).

Image : How OS Work

From the image above, we can understand that within the operating system (OS), there is a kernel that serves as the core of the OS, allowing the applications/programs/software we run to utilize the available hardware resources. Now, let’s take a look at the image below.

What happens in the image above? Clearly, App 1 will function or run normally, while App 2 won’t be able to run due to the required version being different. Docker can certainly be a solution to the problem illustrated in Image : How OS Work. This is because Docker is essentially based on Linux, which itself has two crucial features related to this:

  1. Namespacing: This feature enables the isolation of resources per process or group of processes.
  2. Control Groups (cgroups): This feature limits the amount of resources used per process or group of processes.

With namespacing and cgroups, Docker can create and run containers as depicted below.

Image file and container are closely related components in the Docker ecosystem. The relationship between them can be summarized at this image:

Image file and container
Application running in docker

Conclusion

So, it’s imperative for software developers to familiarize themselves with Docker and consider installing it promptly. Docker offers numerous advantages that significantly streamline the development and deployment processes. By encapsulating applications and their dependencies into containers, Docker reduces complexity, enhances flexibility, and resolves software dependency issues. Therefore, Docker has become an indispensable tool in modern software development, and every software developer should have a solid understanding of its concepts and capabilities.

Next part I will share about docker client and docker image

--

--

Farid Tri Wicaksono
Life at Telkomsel

technology enthusiast, the stupid programmer who likes to learn