<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Containers on Post a Post</title><link>https://hernan941.com/en/tags/containers/</link><description>Recent content in Containers on Post a Post</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><managingEditor>hrwgallardo@gmail.com (Hernán)</managingEditor><webMaster>hrwgallardo@gmail.com (Hernán)</webMaster><copyright>Hernán Gallardo Palma (CC BY-NC 4.0)</copyright><lastBuildDate>Tue, 31 Mar 2026 11:00:00 -0300</lastBuildDate><atom:link href="https://hernan941.com/en/tags/containers/index.xml" rel="self" type="application/rss+xml"/><item><title>Docker 101: containers, kernel and layers</title><link>https://hernan941.com/en/posts/docker101/</link><pubDate>Tue, 31 Mar 2026 11:00:00 -0300</pubDate><author>hrwgallardo@gmail.com (Hernán)</author><guid>https://hernan941.com/en/posts/docker101/</guid><description>&lt;p&gt;If you&amp;rsquo;re in the software world, chances are you&amp;rsquo;ve used Docker. And if not, here&amp;rsquo;s a definition:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;Docker is a platform for developing, packaging and running containers. Important word: containers, which are isolated environments that include everything your software needs to work. These containers are created from images, immutable and reusable templates defined through a Dockerfile. Thanks to this, the same image can be used in development, testing and production, becoming a consistent unit of work in a distributed world.&lt;/p&gt;&#10;&lt;p&gt;There are also other concepts that tend to be overlooked: volumes, which let you persist data, and networks, which connect containers to each other. All of this within an ecosystem like Docker Hub, which offers thousands of ready-to-use images.&lt;/p&gt;&#10;&lt;/blockquote&gt;</description><content:encoded><![CDATA[<p>If you&rsquo;re in the software world, chances are you&rsquo;ve used Docker. And if not, here&rsquo;s a definition:</p>
<blockquote>
<p>Docker is a platform for developing, packaging and running containers. Important word: containers, which are isolated environments that include everything your software needs to work. These containers are created from images, immutable and reusable templates defined through a Dockerfile. Thanks to this, the same image can be used in development, testing and production, becoming a consistent unit of work in a distributed world.</p>
<p>There are also other concepts that tend to be overlooked: volumes, which let you persist data, and networks, which connect containers to each other. All of this within an ecosystem like Docker Hub, which offers thousands of ready-to-use images.</p>
</blockquote>
<p>I think knowing that, you could already start working and integrating containers into your workflow. But we don&rsquo;t stop here, let&rsquo;s go a little further.</p>
<p><img src="https://unsplash.com/photos/P6WRariZ-8M/download?force=true&amp;w=1600" alt="Whale tail emerging from the ocean"></p>
<h2 id="before-the-whales">Before the whales</h2>
<p>Before Docker there were virtual machines (VMs), which are, in essence, a complete emulation of a physical computer inside another one. Each VM acts as an independent machine, with its own virtual CPU, RAM and storage, which lets you run operating systems and applications in an isolated and secure way.</p>
<p>We could ask ourselves: why not keep using virtual machines? But there&rsquo;s an architectural drawback: the weight and volume of the box exceed those of its contents; that is, the system is wasting resources.</p>
<p>Each instance has to load and run a full operating system (Ubuntu, Debian, Windows or another), which takes a lot of resources. VM disk images usually take up gigabytes, and the boot process can take several minutes, even for simple applications. This creates overhead that affects both performance and system efficiency.</p>
<h2 id="using-the-kernel">Using the kernel</h2>
<p>Containers, unlike VMs, don&rsquo;t emulate a complete computer or require a separate operating system. Instead, they share the host operating system&rsquo;s kernel and isolate only the processes and resources needed to run an application. It&rsquo;s operating-system-level virtualization. This removes much of the overhead, allowing more efficient use of resources and near-instant deployment.</p>
<p>A good way to picture it is to imagine a VM as a detached house: it has its own foundations, pillars, electrical system and plumbing. Containers, on the other hand, are like apartments in a modern building. Each apartment shares the main structure, the electrical system and the plumbing. And yet each apartment has everything it needs to live comfortably and independently.</p>
<p><img src="https://unsplash.com/photos/XpyRouTu6NY/download?force=true&amp;w=1600" alt="Blue Building"></p>
<p>Thanks to this we get Docker&rsquo;s key values, particularly efficiency and resource optimization versus virtual machines:</p>
<ul>
<li>Portability: it works everywhere.</li>
<li>Efficiency and resource optimization: lots of containers.</li>
<li>Isolation and standardization: unit of work.</li>
</ul>
<h2 id="namespaces-and-cgroups">Namespaces and cgroups</h2>
<p>Containers work on top of the kernel in an isolated way through two mechanisms: namespaces and cgroups.</p>
<p>A namespace abstracts global system resources so that processes believe they have their own isolated instance. Changes made to a resource are visible only to the processes that belong to the same namespace, remaining invisible to the rest.</p>
<p>Currently, the Linux kernel has 8 types:</p>
<table>
	<thead>
			<tr>
					<th>Namespace</th>
					<th>Resource it isolates</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>cgroup</td>
					<td>Root directory of control groups (cgroup).</td>
			</tr>
			<tr>
					<td>IPC</td>
					<td>Inter-process communication (System V IPC, POSIX message queues).</td>
			</tr>
			<tr>
					<td>Network</td>
					<td>Network devices, protocol stacks, ports, etc.</td>
			</tr>
			<tr>
					<td>Mount</td>
					<td>Filesystem mount points.</td>
			</tr>
			<tr>
					<td>PID</td>
					<td>Process IDs (lets a process be PID 1).</td>
			</tr>
			<tr>
					<td>Time</td>
					<td>Boot and monotonic clocks.</td>
			</tr>
			<tr>
					<td>User</td>
					<td>User and group IDs (lets you be root inside the namespace).</td>
			</tr>
			<tr>
					<td>UTS</td>
					<td>Hostname and NIS domain name.</td>
			</tr>
	</tbody>
</table>
<p>If namespaces decide what you can see, cgroups decide how much you can use.</p>
<p>Cgroups let you allocate system resources (CPU, memory, network bandwidth or a combination) among user-defined groups of tasks (processes). And they go further, letting you monitor the consumption of the configured groups, restrict access to certain resources or set limits. They even let us adjust limits and priorities dynamically. With these mechanisms we achieve isolation.</p>
<h2 id="docker-operates-on-immutable-layers">Docker operates on immutable layers</h2>
<p>An immutable layer is a set of read-only files that records a specific state change in the image. Since they can&rsquo;t be altered, Docker reuses them across multiple containers without duplicating disk space, guaranteeing that the environment is always identical and predictable (determinism). Any later modification doesn&rsquo;t edit the base layer, but generates a new one on top of it, protecting the integrity of the original source.</p>
<p>Working across layers is possible thanks to the concept of UnionFS. This engine takes folders in different layers and &ldquo;merges&rdquo; them virtually so they look like a traditional filesystem. This way we get immutable layers working in harmony, making it possible to spin up disposable infrastructure that is completely replicable.</p>
<p><img src="/images/layers.webp" alt="Docker immutable layers"></p>
<h2 id="communication-and-networking">Communication and networking</h2>
<p>The network namespace is what isolates the network. Each container operates as if it had its own network card and its own IP. Based on this, to connect containers we need a &ldquo;switch&rdquo;, a bridge that allows interaction, as if it were a physical network, creating virtual cabling through a subnet.</p>
<p>But there&rsquo;s a problem: IPs are ephemeral and, so we don&rsquo;t have to configure IPs all the time, the internal DNS server steps in, intercepting the request and returning the current IP, or rather the service name. These 3 mechanisms let us keep communication fast, secure and reliable.</p>
<h2 id="docker-and-its-friends">Docker and its friends</h2>
<p>However, Docker is just the unit of work. In modern professional applications (like those using Django or FastAPI), we rarely work with a single container; we usually need a database, a backend, a worker and a frontend working together. This is where Docker Compose comes in as the orchestra conductor. With a single configuration file, you can define a complete infrastructure for a digital product.</p>
<p>Other technologies like Kubernetes or Docker Swarm let us orchestrate at a larger scale.</p>
<p>With that, I think that&rsquo;s enough whales for one day, maybe for a week, maybe for a good while. I hope it taught you something, and remember that all of these technologies draw heavily from others like operating systems, virtualization and networking&hellip; and remember: if you&rsquo;re out there working with Docker, don&rsquo;t forget to create your <code>.dockerignore</code>.</p>
<p><img src="https://unsplash.com/photos/WeUIHNHbs6o/download?force=true&amp;w=1920" alt="More whales"></p>
<hr>
<p><strong>Note:</strong></p>
<p>Docker Compose is great for development and testing, but in production you shouldn&rsquo;t put the database in a container. A database needs real persistence, high availability and good performance tuning. For production, it&rsquo;s safer to use managed services (AWS RDS, Cloud SQL) or dedicated VMs with backups, replicas and serious monitoring.</p>
<hr>
<h2 id="resources">Resources</h2>
<ul>
<li><a href="https://github.com/ivanmorenoj/how-containers-works">How containers works</a></li>
<li><a href="https://docs.docker.com/get-started/docker-concepts/building-images/understanding-image-layers/#additional-resources">Understanding image layers (Docker Docs)</a></li>
<li><a href="https://sehun.me/layers-of-docker-image101-bca5beead44">Layers of Docker image 101</a></li>
</ul>
]]></content:encoded></item></channel></rss>