What is a container?
The "works on my machine" problem, what a container is, how it differs from a virtual machine, what images are and what Docker is used for.
The problem: “it works on my machine”
You finish a web application. On your computer it works perfectly. You hand it to a teammate and it won’t start: she has a different version of Node, a system library is missing and her database is configured differently. Then you deploy it to the server and it fails again, for a different reason.
The code is the same on all three computers. What changes is everything else: the operating system, the installed versions, the configuration variables, the files the app expects to find.
Docker solves exactly that: it packages your application together with everything it needs to run, so it works the same everywhere.
What is a container?
A container is an isolated process running on your computer with its own filesystem, its own network and its own environment variables. From the inside it looks like a complete Linux computer; from the outside it’s just one more program.
The analogy comes from shipping containers. Before they existed, every ship loaded sacks, barrels and crates of different sizes, and loading or unloading was slow and fragile. The standard container changed everything: no matter what’s inside, every crane, ship and truck knows how to move it.
Software works the same way: it doesn’t matter whether your app is Node, Python or Java. If it’s in a container, any machine with Docker knows how to run it.
Container vs. virtual machine
A virtual machine (VM) simulates a complete computer, with its own entire operating system. A container shares the system kernel with the machine it runs on and only brings the files its app needs.
| Virtual machine | Container | |
|---|---|---|
| What it includes | A complete operating system | Only the app and its dependencies |
| Typical size | Several GB | From a few MB |
| Startup time | Minutes | Seconds or less |
| How many fit on a laptop | A few | Dozens or hundreds |
| Isolation | Very strong | Strong, but they share the kernel |
They're not enemies
In the cloud it’s very common to run containers inside virtual machines: the VM isolates customers from each other and the containers organize each customer’s applications.
Image and container
These two terms appear throughout the course and they’re easy to mix up:
- An image is the template: a read-only package with the filesystem and configuration of the app (for example, “nginx version 1.27”).
- A container is a running instance of that image.
The relationship is like a recipe and cakes: from one recipe you can bake many cakes, and each one can be decorated differently without changing the recipe. From one image you can create many containers.
image nginx:1.27
├── container "web-1"
├── container "web-2"
└── container "testing"What is Docker?
Docker is the tool that builds images, shares them and runs containers. It has several pieces:
| Piece | What it’s for |
|---|---|
| Docker Engine | The service running in the background that manages containers |
| Docker CLI | The docker command you type in the terminal |
| Docker Desktop | The app for Windows and macOS that installs all of the above |
| Docker Hub | An online registry with thousands of ready-to-use images |
| Docker Compose | A tool to run several apps together from one file |
Docker is used by everyone from students to companies like Spotify, PayPal or Mercado Libre. If you work in web development, backend, data or DevOps, you’ll find it in almost every project.
What it’s used for
- Identical development environments for everyone: the team starts the app and its database with a single command.
- Trying things without installing: want PostgreSQL 16 or Redis? You run a container and delete it when you’re done, without cluttering your computer.
- Deployment: the same image you tested on your laptop is the one running in production.
- Microservices: each part of the system lives in its own container and is updated separately.
- CI/CD: automated tests run inside clean containers every time.
Your practice terminal
In every lesson you’ll find a terminal like this one. It has a simulated Docker that runs inside your browser: you can download images, create containers and build your own images without installing anything. The Reset button makes it brand new again.
It's a simulation
The terminal imitates the behavior and messages of real Docker, but it doesn’t download anything from the internet: the images are practice versions. When you install Docker (in the next lesson), every command in the course works the same way on your computer.
Try it: type docker --version and press Enter. Then try docker --help to see the list of commands.
Test what you learned
Challenge
Before moving on, think about a project of your own (a page, an API, an assignment with a database) and answer:
- What would another person have to install to run it on their computer?
- Which parts could go in separate containers?
Then, in the terminal, run docker --help and find which command lists containers and which one lists images.
See a sample answer
An online shop built with Node and PostgreSQL would need: the right Node version, the npm dependencies, a PostgreSQL database with its user and password, and the configuration variables. In containers, the Node app would go in one and PostgreSQL in another.
In docker --help, ps lists containers (“List containers”) and images lists images (“List images”). You’ll use them in lessons 4 and 8.
