6 min read

Docker - What It Is, What It's For and Core Concepts

1. The Problem Docker Solves

“It works on my machine.” Few phrases sum up so well a problem that has plagued (and still plagues) development teams: code that runs perfectly on the developer’s laptop but breaks on the production server — because the Python version is different, a system library is missing, an environment variable wasn’t set, or the operating system simply behaves differently.

Docker solves exactly that: it packages an application together with everything it needs to run — code, dependencies, system libraries, environment variables, configuration — into an isolated, portable unit called a container. That unit runs the same way anywhere Docker is installed: on the developer’s laptop, on the CI server or in production. This is the first part of a series that goes from zero to advanced Docker: today the focus is understanding the problem it solves, the core concepts and how they fit together.

2. Containers vs Virtual Machines

The most common comparison when explaining Docker is with virtual machines (VMs), because both solve a similar problem — isolating and packaging applications — but in very different ways.

A virtual machine virtualizes the entire hardware: each VM runs its own complete operating system (kernel included), managed by a hypervisor. This guarantees strong isolation, but at a high cost: each VM consumes hundreds of MBs to a few GBs of disk and memory just for the OS, and takes tens of seconds to minutes to boot.

A container, on the other hand, virtualizes at the operating system level: all the containers on a machine share the same host kernel, but each one sees its own isolated filesystem, processes and network — using Linux kernel features such as namespaces (isolating what a process can see) and cgroups (CPU/memory limits). As a result, containers are much lighter: a few MBs to a few hundred MBs, starting in milliseconds to a few seconds.

┌─────────────────────────┐        ┌─────────────────────────┐
│   VM 1    │    VM 2      │        │  Container 1│Container 2│
│  ┌─────┐  │   ┌─────┐    │        │  ┌───────┐  │ ┌───────┐ │
│  │ App │  │   │ App │    │        │  │  App  │  │ │  App  │ │
│  ├─────┤  │   ├─────┤    │        │  ├───────┤  │ ├───────┤ │
│  │ OS  │  │   │ OS  │    │        │  │ Libs  │  │ │ Libs  │ │
│  └─────┘  │   └─────┘    │        │  └───────┘  │ └───────┘ │
├───────────┴──────────────┤        ├─────────────┴───────────┤
│        Hypervisor        │        │      Docker Engine       │
├───────────────────────────┤        ├───────────────────────────┤
│    Host OS + Hardware     │        │    Host OS + Hardware     │
└───────────────────────────┘        └───────────────────────────┘

This doesn’t mean containers replace VMs in every scenario — VMs are still the right choice when isolation needs to be total (for example, running workloads from multiple untrusted customers on the same physical machine) or when you need a different kernel from the host’s. But for the most common case — packaging and distributing applications consistently — containers win on lightness, startup speed and density (how many workloads fit on the same machine).

3. The Three Core Concepts: Images, Containers and Registries

Docker’s whole mental model revolves around three pieces:

  • Image: a read-only package with everything an application needs to run — filesystem, binaries, libraries, application code and metadata (such as which command to run on startup). It’s built from a Dockerfile (the subject of Article 3 in this series) and organized into stacked layers, which allows parts that were already built to be reused across different builds.
  • Container: a running instance of an image. If the image is the “blueprint” (like a class in object-oriented programming), the container is the “object” instantiated from it — with a running process, a writable filesystem on top of the read-only image, and its own isolated network space. You can run multiple containers from the same image, each independent of the others.
  • Registry: a repository for storing and distributing images. Docker Hub is the default public registry (home to official images like python, postgres, nginx), but there are private registries (AWS ECR, Google Artifact Registry, GitHub Container Registry) for a company’s internal images.

The typical flow connects these three pieces: you write a Dockerfile, build an image from it, push that image to a registry, and on any machine with Docker installed you can pull it and run one or more containers from it.

Dockerfile → (build) → Image → (push) → Registry
                                             │
                                         (pull)
                                             │
                                             ▼
                                       Local image → (run) → Container

4. Installing Docker

Docker is available for Linux, macOS and Windows. On Linux distributions, the official package (not the generic docker.io from some repositories, which tends to be outdated) is installed like this:

# Debian/Ubuntu — official convenience script
curl -fsSL https://get.docker.com | sh

# Then, to run docker without sudo (requires logging out and back in):
sudo usermod -aG docker $USER

On macOS and Windows, the most common approach is to install Docker Desktop, which bundles the engine, a lightweight Linux VM (needed because Docker relies on Linux kernel features) and a graphical interface.

Once installed, confirm it’s working:

docker --version
docker run hello-world

The second command downloads a minimal image from Docker Hub and runs a container from it (which prints a confirmation message and exits) — it’s the official “hello world” of the Docker ecosystem, useful to validate that the engine is running and allowed to download images.

5. A First Container in Practice

To move beyond theory, a real example: running an Nginx web server without installing anything but Docker on the machine.

docker run -d -p 8080:80 --name my-nginx nginx

Breaking down the command:

  • docker run — creates and starts a container from an image.
  • -d (detached) — runs the container in the background, giving you the terminal back immediately.
  • -p 8080:80 — maps port 8080 on the host machine to port 80 inside the container (where Nginx listens by default).
  • --name my-nginx — gives the container an easy-to-reference name, instead of an automatically generated id.
  • nginx — the image to use. Since it doesn’t exist locally yet, Docker automatically pulls it from Docker Hub before running.

Opening http://localhost:8080 in the browser already shows the Nginx default page. To check that the container is running and then remove it:

docker ps                    # list running containers
docker stop my-nginx         # stop the container
docker rm my-nginx           # remove the (already stopped) container

Note that docker stop and docker rm are separate steps — stopping a container doesn’t remove it, it just ends the process inside it. This is intentional: it lets you inspect the final state of a container that failed before discarding it. Everyday commands like these (run, exec, logs, ps, build) are the full subject of the next article.

6. Conclusion and Next Steps

In this first part, we saw the real problem Docker solves (“it works on my machine”), how containers differ from virtual machines in lightness and speed, the three concepts that hold up the whole ecosystem — images, containers and registries — and ran our first container end to end. In the next article, the focus moves to the commands that really become daily habits: run, exec, logs, ps and build, with examples of real containers beyond “hello world”.


References:

  1. Docker Documentation — Get Started
  2. Docker Documentation — Docker Overview