Running Your First Container (Hello World)
LEVEL 0
The Problem
You have Docker installed. Now what?
Let’s run something. Something simple that proves the entire chain works — from your command to a running container.
LEVEL 1
The Concept — The Handshake
The Concept
Running your first container is like shaking hands with Docker. It’s a test of communication.
When you run docker run hello-world, you’re asking:
- “CLI, can you hear me?”
- “Daemon, are you there?”
- “Registry, can we talk?”
- “Image, do you exist?”
- “Container, will you run?”
If all goes well, you get a friendly message confirming everything works.
LEVEL 2
The Mechanics — The Command
The Mechanics
Open your terminal and type:
docker run hello-world
If this is your first time, you’ll see something like:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:...
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
...
That output is coming from inside the container.
LEVEL 3
What Actually Happened
Let’s break down the sequence:
Step 1: CLI → Daemon
Your docker run hello-world command goes from the CLI to the Docker daemon via a REST API call.
Step 2: Daemon checks for image locally
The daemon looks in its local image store. Is hello-world:latest there? First time, no.
Step 3: Daemon → Docker Hub Since the image isn’t local, the daemon contacts Docker Hub (the default registry) and downloads the image. You see this as the “Pulling from library/hello-world” messages.
Step 4: Daemon creates container From the downloaded image, the daemon creates a container — setting up namespaces, cgroups, the filesystem.
Step 5: Container runs The container’s startup command runs. For hello-world, it’s a tiny program that prints the message you saw.
Step 6: Container exits The program finishes. The container stops.
Step 7: Output streamed The output is streamed back through the daemon to the CLI to your terminal.
LEVEL 4
The Hello-World Image
The hello-world image is intentionally minimal. It contains:
- A tiny binary (about 13KB)
- That binary just prints a message and exits
Its purpose is purely to verify Docker is working. There’s no ongoing process, no service, just a quick test.
If you run it again:
docker run hello-world
This time it won’t need to pull the image — it’s already local. It’ll go straight to creating and running the container.