Docker

Docker: The Plain English Guide

Forget the hype. This guide cuts through the noise and tells you what Docker is, why you should care, and how it’s different from the old way of doing things (we’re looking at you, VMs).

Table of Contents


The Foundation: What is a Container?

First, let’s get one thing straight: Docker didn’t invent containers. They just made them easy enough for normal people to use.

A container is basically a way to trap your application and all its junk (libraries, tools, config files) into a neat little box. This box can run anywhere—your laptop, a server, the cloud—and your app will work exactly the same. No more “it works on my machine” excuses.

This magic is pulled off by two core Linux kernel tricks:

  1. Namespaces: These provide isolation. They wrap a global system resource in an abstraction that makes it appear to the processes within the namespace that they have their own isolated instance of that resource. For example, a process can have its own private network stack, process tree (PID 1), and user list.

  2. Control Groups (cgroups): These are the resource police. They stop one greedy container from hogging all the CPU and memory, ensuring every container plays nice and shares the hardware.

So, a container is just a regular process with some walls built around it, running on the same OS kernel as everything else.

The Docker Revolution

Before Docker, using container technology (like LXC) was a massive pain. It was a tool for hardcore system admins only.

Docker, launched in 2013, changed the game by giving us a simple toolkit and a clear workflow:

This ecosystem made it dead simple to Build, Ship, and Run any app, anywhere, without headaches.


Containers vs. Virtual Machines (VMs)

This is where people get confused, but it’s simple. Both give you isolation, but they do it very differently.

Virtual Machines (VMs): The Old Way

A VM pretends to be an entire computer. It needs a full copy of an operating system (like Windows or another Linux) to run. This is why they are huge (gigabytes) and slow to start (minutes).

Analogy: A VM is like building a brand new, fully-furnished house for every app you want to run.

+---------------------+  +---------------------+
|      App A          |  |      App B          |
+---------------------+  +---------------------+
|   Bins / Libs       |  |   Bins / Libs       |
+---------------------+  +---------------------+
|    Guest OS         |  |    Guest OS         |
+---------------------+  +---------------------+
----------------------------------------------+
|                  Hypervisor                  |
+----------------------------------------------+
|                  Host OS                     |
+----------------------------------------------+
|                  Hardware                    |
+----------------------------------------------+

Container Architecture

Containers virtualize the operating system, not the hardware. All containers on a host share the host OS kernel. This makes them extremely lightweight, fast, and efficient because they don’t carry the overhead of a full guest OS.

+-----------+ +-----------+ +-----------+
|   App A   | |   App B   | |   App C   |
+-----------+ +-----------+ +-----------+
| Bins/Libs | | Bins/Libs | | Bins/Libs |
+-----------+ +-----------+ +-----------+
-----------------------------------------+
|             Container Engine          |
+-----------------------------------------+
|                 Host OS                 |
+-----------------------------------------+
|                 Hardware                |
+-----------------------------------------+

Comparison Table

Feature Virtual Machines (VMs) Containers
Isolation Strong: Full hardware and kernel isolation. Weaker: Process-level isolation, shared kernel.
Size Large: Gigabytes (GBs), includes a full OS. Small: Megabytes (MBs), includes only app deps.
Startup Time Slow: Minutes, as it boots a full OS. Fast: Milliseconds to seconds.
Resource Usage High: Significant CPU and memory overhead per VM. Low: Minimal overhead, very efficient.
Portability Limited: Tied to the hypervisor configuration. High: Runs on any OS with a container engine.
Best For Running different OSs on one server; full isolation. Microservices, CI/CD pipelines, app packaging.

The Docker Ecosystem and Beyond

The Docker journey didn’t stop with single containers. The ecosystem has grown to manage complex, distributed applications.

So, a container is just a regular process with some walls built around it, running on the same OS kernel as everything else.

Why Should a Developer Use Containers?

Alright, enough theory. Here’s why this matters for your day-to-day coding:


The Docker Revolution

Before Docker, using container technology (like LXC) was a massive pain. It was a tool for hardcore system admins only.


How to Install Docker

Getting Docker is easy. Here’s the quick and dirty guide. For the most up-to-date steps, always check the official Docker docs.


Run Your First Container: Hello World

Okay, Docker is installed. Let’s make sure it works. The hello-world container is the simplest way to test your setup.

Just run this command in your terminal:

docker run hello-world

When you run this, Docker will:

  1. Check if you have the hello-world image on your machine.
  2. Since you don’t, it will download (or “pull”) it from Docker Hub.
  3. It will then create and run a new container from that image.
  4. The container will print a confirmation message and then exit.

You should see output that looks like this:

Hello from Docker!
This message shows that your installation appears to be working correctly.
... (some more text explaining the steps)

If you see that message, congratulations! Your Docker installation is working.

Basic Docker CLI Commands

You’ve run hello-world, but that’s just the beginning. Here are the essential commands you’ll use every day.

We’ll use the nginx web server image as an example, as it’s small and useful.

Managing Containers

Managing Images