Introduction to Docker

This article provides an introduction to Docker, one of the most widely used container technologies today. It covers what Docker is, why it has become so popular, its main components and architecture, and how it differs from other container solutions. The article also includes a practical lab to run and interact with containers, helping bridge the gap between theory and hands-on experience.
Introduction to Docker

Recap

In a previous article, I shared my learning journey through an Introduction to Containers, covering the core concepts behind container technologies and how they differ from traditional virtual machines. That article laid the foundation for understanding why containers have become such a powerful and widely adopted approach.

Following the same learning path, this article continues that journey by focusing on one of the most popular container technologies today: Docker.

For readers who are new to the topic, the previous article provides valuable context. For those who already read it, this piece builds on that knowledge and start

What is Docker?

It is an open-source platform that simplifies the creation, deployment, and execution of applications inside containers. image Docker allows developers to package an application together with all its dependencies into a container, ensuring that the application runs consistently across any environment.

Other Container Technologies

Docker is currently the most popular container management system, but as mentioned earlier, it is not the only one.

LXC (Linux Containers)

image The goal of LXC is to create an environment as close as possible to a standard Linux installation without the need for a separate kernel.

  • It is based on liblxc.

  • Version 5.0 is supported until June 2027.

  • It is widely used in virtualization environments such as Proxmox VE, which provides an easy and intuitive way to manage LXC containers, almost as if they were virtual machines, allowing the allocation of resources such as CPU, memory, and more.

Podman

imagePodman is a Linux-native, open-source, daemonless tool designed to simplify searching, building, sharing, and deploying applications using containers.

  • Daemonless: It does not require a centralized daemon like Docker, which improves security by avoiding the need to run with root privileges and provides a lighter environment.

  • Docker compatibility: It is compatible with Docker. Most commands are identical, and it is also compatible at the image level.

  • Ecosystem: It has a smaller ecosystem compared to Docker and is not as popular.

  • Open source: Open-source software, licensed under Apache.

  • GUI: It includes a desktop application called Podman Desktop.

Why Docker?

  • Community: There is a large community contributing both to Docker’s development and to Docker images. Numerous forums, tutorials, and online courses are available.

  • Ease of use: It offers a simple user interface and intuitive commands, along with various graphical tools.

  • Enterprise support: Many companies provide support and Docker-based solutions for enterprise environments.

  • Licensing: Docker does not require a license for use.

  • Compatibility: Docker is compatible with multiple platforms, operating systems, and architectures, making installation and deployment easier.

Main Docker Components

Docker Engine

It acts as a client–server application composed of:

  • Docker daemon: Called dockerd, it is the Docker daemon or service.

  • Docker API: A REST API that allows interaction between the CLI and the Docker Engine.

User Interface

  • Docker CLI: Docker’s command-line interface. To make things easier, a CLI Cheat Sheet is available.

  • Docker Desktop: An all-in-one application that provides a graphical interface and a complete environment for working with Docker. On Windows and macOS, it includes a lightweight Linux-based VM. There are alternatives such as Rancher Desktop.

imageOther Docker Components

  • Images: A Docker image is a read-only template that defines which software and configurations a container includes. Images are immutable, but they can be versioned to introduce changes.

  • Containers: A Docker container is a running instance of an image. Containers are isolated environments where applications run.

  • Registry: Also known as Docker Hub, it is a registry or repository for public and private container images. Developers can use Docker Hub to search for and download images, as well as to share their own. image

Advantages of Docker

  • Consistency: Ensures that the application runs the same way across all environments.

  • Fast Deployment: Allows rapid creation and destruction of containers, accelerating the development and deployment cycle.

  • Ease of Integration: Compatible with various tools and services, making it easier to integrate into CI/CD workflows.

Docker has transformed the way applications are developed, deployed, and managed. It provides a robust and efficient solution for operating-system-level virtualization, enabling developers and operations teams to work in a more agile and effective manner. With a clear understanding of Docker’s components and benefits, we are ready to dive into the practical side and experience firsthand how Docker can simplify and improve our workflows.

Docker Installation

This article is introductory, so it does not aim to provide a step-by-step guide on how to install Docker on different operating systems.
That said, it is worth mentioning that Docker is available for the most popular platforms: Windows, GNU/Linux, and macOS.

Docker Engine

Also known as Docker CE, it is Docker’s core engine and is essential for it to function. image Below are links for installation on common distributions such as Ubuntu, Debian, and CentOS.

For other Linux installations, you can refer to the official documentation.

Docker Desktop

Docker’s official application. It provides a graphical user interface and also includes the Docker Engine.

  • Docker Desktop for Windows (it is installed using Hyper-V or WSL. There is no strict preference for either technology; it depends on what is already installed and configured, as well as the planned use case)

  • Docker Desktop for Linux

  • Docker Desktop for macOS (Docker Desktop supports the latest macOS version and the two previous ones. As new versions are released, the oldest one is dropped from support by Docker)

Docker CLI

A graphical interface is not always available—for example, when running on servers—so most tutorials and courses continue to use the Docker CLI for examples, and naturally, we will follow the same approach.

Example on Windows (PowerShell)

image

Running Our First Container

docker run hello-world

As mentioned earlier, on Windows it is necessary to have Docker Desktop installed (and running), since it includes the Docker Engine. If it is not running, an error like the following will be returned:

imageIf the Docker Engine is running, after executing the command mentioned above you will get the following output:

imageMany interesting things can be observed in this execution, where Docker itself explains what happened behind the scenes.

View from Docker Desktop – Containers Section

image

View from Docker Desktop – Images Section

image

Summary

Finally, we see in practice the concepts introduced earlier, where the client connects to the Docker Engine to check whether it has the hello-world image. Since it is not available locally, it connects to Docker Hub to download it (pull). Then, the Docker Daemon creates a container from that now-local image and runs it, producing output that is sent directly to the client, which in turn displays it in the terminal.

The Docker Desktop GUI also shows the container that was executed (with an assigned name and ID), indicating which image it was created from. We can then see the image itself, along with its tag and ID, when it was created in the registry, and the amount of disk space it occupies.

Bonus

We can use and try Docker without installing it by using a web browser through the Play with Docker website. You need to sign in, and then you will have 2 hours available to experiment.

image

Lab

We are going to run an Alpine Linux container, a super lightweight distribution that is growing in popularity. To do this, let’s run the following command:

docker run -it alpine sh

The docker run command is used to run a Docker image in a container. The -it parameter starts an interactive session.

After the image has been downloaded, we will get a sh terminal prompt like the following:

/#

We now have a Linux container running. We can use it as if it were a VM. Just to test it, let’s install a package.

We execute the following command to verify that TCP/IP is working correctly:

# ping -c 3 localhost
PING localhost (::1) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.028 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.025 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.022 ms

We will install the cURL package (which stands for Client for URLs, a command-line tool used to transfer data using URLs) inside the container to extend its capabilities.

# Update the repository database
apk update

# Install the curl package
apk add curl

Once the installation process has finished, we can test curl as follows to find out our public IP address:

curl ifconfig.co

To exit the container and stop its execution:

exit

Closing Remarks

There is much more to explore in the world of Docker, but covering those topics in depth will require another article.

I hope the community receives this one positively, and based on the feedback I get, I’ll set out to write additional articles that dive deeper into the Docker ecosystem and help further explore this technology.


Write a comment
No comments yet.